Skip to content

Commit fcbb3ae

Browse files
fix contact matching pointers again
1 parent e1f79bc commit fcbb3ae

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

imessage/bluebubbles/api.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ func (bb *blueBubbles) GetChatsWithMessagesAfter(minDate time.Time) (resp []imes
684684
}
685685

686686
func (bb *blueBubbles) matchHandleToContact(address string) *Contact {
687-
688687
var matchedContact *Contact
689688

690689
numericAddress := numericOnly(address)
@@ -703,18 +702,19 @@ func (bb *blueBubbles) matchHandleToContact(address string) *Contact {
703702
var phoneStrings = convertPhones(c.PhoneNumbers)
704703

705704
// check for exact matches for either an email or phone
706-
if strings.Contains(address, "@") {
707-
if containsString(emailStrings, address) {
708-
contact = &c
709-
}
705+
if strings.Contains(address, "@") && containsString(emailStrings, address) {
706+
contact = &Contact{} // Create a new instance
707+
*contact = c
710708
} else if containsString(phoneStrings, numericAddress) {
711-
contact = &c
709+
contact = &Contact{} // Create a new instance
710+
*contact = c
712711
}
713712

714713
for _, p := range numericPhones {
715714
matchLengths := []int{15, 14, 13, 12, 11, 10, 9, 8, 7}
716715
if containsInt(matchLengths, len(p)) && strings.HasSuffix(numericAddress, p) {
717-
contact = &c
716+
contact = &Contact{} // Create a new instance
717+
*contact = c
718718
}
719719
}
720720

@@ -725,7 +725,8 @@ func (bb *blueBubbles) matchHandleToContact(address string) *Contact {
725725

726726
// Contacts with a source type of "api" are stored on the mac and can be used as fallback in case an imported one isn't found
727727
if contact != nil && matchedContact == nil {
728-
matchedContact = contact
728+
matchedContact = &Contact{} // Create a new instance
729+
*matchedContact = *contact
729730
}
730731
}
731732

0 commit comments

Comments
 (0)