Skip to content

Commit

Permalink
v2: implement note to self avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jun 19, 2024
1 parent d06f4b5 commit 58a1b87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/net v0.26.0
google.golang.org/protobuf v1.34.2
maunium.net/go/mautrix v0.19.0-beta.1.0.20240619195836-2a7a5070fb32
maunium.net/go/mautrix v0.19.0-beta.1.0.20240619204109-68d8ab6896fd
nhooyr.io/websocket v1.8.11
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240619195836-2a7a5070fb32 h1:BiUVpB1hejeuCivlLOv5jKzU/Y8TTwDlQ0i1qO+JGdI=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240619195836-2a7a5070fb32/go.mod h1:cxv1w6+syudmEpOewHYIQT9yO7TM5UOWmf6xEBVI4H4=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240619204109-68d8ab6896fd h1:NZYFpztfJCdynpWJTGOyPcYfr+95zCut/IobMzaKCdU=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240619204109-68d8ab6896fd/go.mod h1:cxv1w6+syudmEpOewHYIQT9yO7TM5UOWmf6xEBVI4H4=
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
9 changes: 9 additions & 0 deletions pkg/connector/chatinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package connector

import (
"context"
"crypto/sha256"
"errors"
"fmt"
"strconv"
Expand Down Expand Up @@ -193,12 +194,19 @@ func (s *SignalClient) makeCreateDMResponse(recipient *types.Recipient) *bridgev
topic = fmt.Sprintf("%s with %s", PrivateChatTopic, recipient.E164)
}
var serviceID libsignalgo.ServiceID
var avatar *bridgev2.Avatar
if recipient.ACI == uuid.Nil {
name = s.Main.Config.FormatDisplayname(recipient)
serviceID = libsignalgo.NewPNIServiceID(recipient.PNI)
} else {
if recipient.ACI == s.Client.Store.ACI {
name = NoteToSelfName
avatar = &bridgev2.Avatar{
ID: networkid.AvatarID(s.Main.Config.NoteToSelfAvatar),
Remove: len(s.Main.Config.NoteToSelfAvatar) == 0,
MXC: s.Main.Config.NoteToSelfAvatar,
Hash: sha256.Sum256([]byte(s.Main.Config.NoteToSelfAvatar)),
}
} else {
// The other user is only present if their ACI is known
members = append(members, makeUserID(recipient.ACI))
Expand All @@ -209,6 +217,7 @@ func (s *SignalClient) makeCreateDMResponse(recipient *types.Recipient) *bridgev
PortalID: s.makeDMPortalKey(serviceID),
PortalInfo: &bridgev2.PortalInfo{
Name: &name,
Avatar: avatar,
Topic: &topic,
Members: members,
IsDirectChat: &isDirectChat,
Expand Down

0 comments on commit 58a1b87

Please sign in to comment.