Skip to content

Commit 461b245

Browse files
committed
Leave out birthday in vcard if ldap entry is empty
1 parent ee83f8d commit 461b245

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

carddav.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ func createVcardFromLdap(entry *ldap.Entry) *vcard.Card {
4848
})
4949
card.SetValue(vcard.FieldUID, entry.GetAttributeValue("uid"))
5050
card.SetValue(vcard.FieldPhoto, fmt.Sprintf("data:image/jpeg;base64,%s", base64.StdEncoding.EncodeToString([]byte(entry.GetAttributeValue("jpegPhoto")))))
51-
card.SetValue(vcard.FieldBirthday, fmt.Sprintf("%s%02s%02s", entry.GetAttributeValue("birthyear"), entry.GetAttributeValue("birthmonth"), entry.GetAttributeValue("birthday")))
51+
if entry.GetAttributeValue("birthyear") != "" || entry.GetAttributeValue("birthmonth") != "" || entry.GetAttributeValue("birthday") != "" {
52+
card.SetValue(vcard.FieldBirthday, fmt.Sprintf("%s%02s%02s", entry.GetAttributeValue("birthyear"), entry.GetAttributeValue("birthmonth"), entry.GetAttributeValue("birthday")))
53+
}
5254
vcard.ToV4(card)
5355
return &card
5456
}

0 commit comments

Comments
 (0)