@@ -878,6 +878,9 @@ func (portal *Portal) handleSignalDataMessage(source *User, sender *Puppet, msg
878878 // If this message is a group change, don't handle it here, it's handled below.
879879 if msg .GetGroupV2 ().GetGroupChange () == nil && portal .Revision < msg .GetGroupV2 ().GetRevision () {
880880 portal .UpdateInfo (genericCtx , source , nil , msg .GetGroupV2 ().GetRevision ())
881+ } else if portal .IsPrivateChat () && portal .UserID () == portal .Receiver && portal .Name != NoteToSelfName {
882+ // Slightly hacky way to make note to self names backfill
883+ portal .UpdateDMInfo (genericCtx , false )
881884 }
882885
883886 switch {
@@ -1554,8 +1557,6 @@ func (portal *Portal) GetDMPuppet() *Puppet {
15541557 return portal .bridge .GetPuppetBySignalID (portal .UserID ())
15551558}
15561559
1557- const PrivateChatTopic = "Signal private chat"
1558-
15591560func (portal * Portal ) UpdateInfo (ctx context.Context , source * User , groupInfo * signalmeow.Group , revision uint32 ) {
15601561 if portal .IsPrivateChat () {
15611562 portal .UpdateDMInfo (ctx , false )
@@ -1567,6 +1568,9 @@ func (portal *Portal) UpdateInfo(ctx context.Context, source *User, groupInfo *s
15671568 }
15681569}
15691570
1571+ const PrivateChatTopic = "Signal private chat"
1572+ const NoteToSelfName = "Signal Note to Self"
1573+
15701574func (portal * Portal ) UpdateDMInfo (ctx context.Context , forceSave bool ) {
15711575 log := zerolog .Ctx (ctx ).With ().
15721576 Str ("function" , "UpdateDMInfo" ).
@@ -1576,12 +1580,18 @@ func (portal *Portal) UpdateDMInfo(ctx context.Context, forceSave bool) {
15761580 puppet := portal .GetDMPuppet ()
15771581
15781582 update := forceSave
1579- if portal .shouldSetDMRoomMetadata () {
1583+ if portal .UserID () == portal .Receiver {
1584+ noteToSelfAvatar := portal .bridge .Config .Bridge .NoteToSelfAvatar .ParseOrIgnore ()
1585+ avatarHash := sha256 .Sum256 ([]byte (noteToSelfAvatar .String ()))
1586+
1587+ update = portal .updateName (ctx , NoteToSelfName ) || update
1588+ update = portal .updateAvatarWithMXC (ctx , "notetoself" , hex .EncodeToString (avatarHash [:]), noteToSelfAvatar ) || update
1589+ } else if portal .shouldSetDMRoomMetadata () {
15801590 update = portal .updateName (ctx , puppet .Name ) || update
15811591 update = portal .updateAvatarWithMXC (ctx , puppet .AvatarPath , puppet .AvatarHash , puppet .AvatarURL ) || update
15821592 }
15831593 topic := PrivateChatTopic
1584- if puppet .Number != "" {
1594+ if portal . bridge . Config . Bridge . NumberInTopic && puppet .Number != "" {
15851595 topic = fmt .Sprintf ("%s with %s" , topic , puppet .Number )
15861596 }
15871597 update = portal .updateTopic (ctx , topic ) || update
0 commit comments