Skip to content

Commit

Permalink
Actually update protobufs
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Dec 21, 2023
1 parent 8260ba1 commit ae60c41
Show file tree
Hide file tree
Showing 17 changed files with 2,301 additions and 2,210 deletions.
6 changes: 3 additions & 3 deletions msgconv/signalfmt/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func Parse(message string, ranges []*signalpb.BodyRange, params *FormatParams) *
switch rv := r.GetAssociatedValue().(type) {
case *signalpb.BodyRange_Style_:
br.Value = Style(rv.Style)
case *signalpb.BodyRange_MentionUuid:
userInfo := params.GetUserInfo(rv.MentionUuid)
case *signalpb.BodyRange_MentionAci:
userInfo := params.GetUserInfo(rv.MentionAci)
if userInfo.MXID == "" {
continue
}
Expand All @@ -96,7 +96,7 @@ func Parse(message string, ranges []*signalpb.BodyRange, params *FormatParams) *
// Maybe use NewUTF16String and do index replacements for the plaintext body too,
// or just replace the plaintext body by parsing the generated HTML.
content.Body = strings.Replace(content.Body, "\uFFFC", userInfo.Name, 1)
br.Value = Mention{UserInfo: userInfo, UUID: rv.MentionUuid}
br.Value = Mention{UserInfo: userInfo, UUID: rv.MentionAci}
}
lrt.Add(br)
}
Expand Down
4 changes: 2 additions & 2 deletions msgconv/signalfmt/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func TestParse(t *testing.T) {
ine: []*signalpb.BodyRange{{
Start: proto.Uint32(6),
Length: proto.Uint32(1),
AssociatedValue: &signalpb.BodyRange_MentionUuid{
MentionUuid: realUser,
AssociatedValue: &signalpb.BodyRange_MentionAci{
MentionAci: realUser,
},
}},
body: "Hello Matrix User",
Expand Down
4 changes: 2 additions & 2 deletions msgconv/signalfmt/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (m Mention) String() string {
}

func (m Mention) Proto() signalpb.BodyRangeAssociatedValue {
return &signalpb.BodyRange_MentionUuid{
MentionUuid: m.UUID,
return &signalpb.BodyRange_MentionAci{
MentionAci: m.UUID,
}
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/signalmeow/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ type ContactAvatar struct {

func StoreContactDetailsAsContact(d *Device, contactDetails *signalpb.ContactDetails, avatar *[]byte) (Contact, *ContactAvatar, error) {
ctx := context.TODO()
existingContact, err := d.ContactStore.LoadContact(ctx, contactDetails.GetUuid())
existingContact, err := d.ContactStore.LoadContact(ctx, contactDetails.GetAci())
if err != nil {
zlog.Err(err).Msg("StoreContactDetailsAsContact error loading contact")
return Contact{}, nil, err
}
if existingContact == nil {
zlog.Debug().Msgf("StoreContactDetailsAsContact: creating new contact for uuid: %v", contactDetails.GetUuid())
zlog.Debug().Msgf("StoreContactDetailsAsContact: creating new contact for uuid: %v", contactDetails.GetAci())
existingContact = &Contact{
UUID: contactDetails.GetUuid(),
UUID: contactDetails.GetAci(),
}
} else {
zlog.Debug().Msgf("StoreContactDetailsAsContact: updating existing contact for uuid: %v", contactDetails.GetUuid())
zlog.Debug().Msgf("StoreContactDetailsAsContact: updating existing contact for uuid: %v", contactDetails.GetAci())
}

existingContact.E164 = contactDetails.GetNumber()
Expand All @@ -87,11 +87,11 @@ func StoreContactDetailsAsContact(d *Device, contactDetails *signalpb.ContactDet
var contactAvatar *ContactAvatar
avatarHash := ""
if avatar != nil && *avatar != nil && len(*avatar) > 0 {
zlog.Debug().Msgf("StoreContactDetailsAsContact: found avatar for uuid: %v", contactDetails.GetUuid())
zlog.Debug().Msgf("StoreContactDetailsAsContact: found avatar for uuid: %v", contactDetails.GetAci())
rawHash := sha256.Sum256(*avatar)
avatarHash = hex.EncodeToString(rawHash[:])
if existingContact.ContactAvatarHash != avatarHash {
zlog.Debug().Msgf("StoreContactDetailsAsContact: avatar changed for uuid: %v", contactDetails.GetUuid())
zlog.Debug().Msgf("StoreContactDetailsAsContact: avatar changed for uuid: %v", contactDetails.GetAci())
var contentType string
if avatarDetails := contactDetails.GetAvatar(); avatarDetails != nil && !strings.HasSuffix(avatarDetails.GetContentType(), "/*") {
contentType = *avatarDetails.ContentType
Expand All @@ -109,13 +109,13 @@ func StoreContactDetailsAsContact(d *Device, contactDetails *signalpb.ContactDet
}
} else {
// Avatar has been removed
zlog.Debug().Msgf("StoreContactDetailsAsContact: no avatar found for uuid: %v", contactDetails.GetUuid())
zlog.Debug().Msgf("StoreContactDetailsAsContact: no avatar found for uuid: %v", contactDetails.GetAci())
if existingContact.ContactAvatarHash != "" {
existingContact.ContactAvatarHash = ""
}
}

zlog.Debug().Msgf("StoreContactDetailsAsContact: storing contact for uuid: %v", contactDetails.GetUuid())
zlog.Debug().Msgf("StoreContactDetailsAsContact: storing contact for uuid: %v", contactDetails.GetAci())
storeErr := d.ContactStore.StoreContact(ctx, *existingContact)
if storeErr != nil {
zlog.Err(storeErr).Msg("StoreContactDetailsAsContact: error storing contact")
Expand Down
2 changes: 1 addition & 1 deletion pkg/signalmeow/protobuf/DeviceName.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ae60c41

Please sign in to comment.