Skip to content

Commit d188d14

Browse files
committed
all: remove unsafe direct store access
1 parent 91b2a32 commit d188d14

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

cmd/mautrix-whatsapp/legacyprovision.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func legacyProvContacts(w http.ResponseWriter, r *http.Request) {
4040
if userLogin == nil {
4141
return
4242
}
43-
if contacts, err := userLogin.Client.(*connector.WhatsAppClient).Device.Contacts.GetAllContacts(r.Context()); err != nil {
43+
if contacts, err := userLogin.Client.(*connector.WhatsAppClient).GetStore().Contacts.GetAllContacts(r.Context()); err != nil {
4444
hlog.FromRequest(r).Err(err).Msg("Failed to fetch all contacts")
4545
exhttp.WriteJSONResponse(w, http.StatusInternalServerError, Error{
4646
Error: "Internal server error while fetching contact list",

pkg/connector/handlewhatsapp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (wa *WhatsAppClient) rerouteWAMessage(ctx context.Context, info *types.Mess
264264
Msg("Forced LID DM sender to phone number in own message sent from another device")
265265
info.Chat = info.RecipientAlt.ToNonAD()
266266
} else if info.Sender.Server == types.BotServer && info.Chat.Server == types.HiddenUserServer {
267-
chatPN, err := wa.Device.LIDs.GetPNForLID(ctx, info.Chat)
267+
chatPN, err := wa.GetStore().LIDs.GetPNForLID(ctx, info.Chat)
268268
if err != nil {
269269
wa.UserLogin.Log.Err(err).
270270
Str("message_id", info.ID).
@@ -423,7 +423,7 @@ func (wa *WhatsAppClient) handleWAReceipt(ctx context.Context, evt *events.Recei
423423
if !evt.MessageSender.IsEmpty() {
424424
messageSender = evt.MessageSender
425425
} else if evt.Chat.Server == types.GroupServer && evt.Sender.Server == types.HiddenUserServer {
426-
lid := wa.Device.GetLID()
426+
lid := wa.GetStore().GetLID()
427427
if !lid.IsEmpty() {
428428
messageSender = lid
429429
}

pkg/connector/id.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (wa *WhatsAppClient) makeEventSender(ctx context.Context, id types.JID) bri
3939
} else if id.Server == types.DefaultUserServer {
4040
senderLoginJID = id
4141
} else if id.Server == types.HiddenUserServer {
42-
pn, err := wa.Device.LIDs.GetPNForLID(ctx, id)
42+
pn, err := wa.GetStore().LIDs.GetPNForLID(ctx, id)
4343
if err != nil {
4444
zerolog.Ctx(ctx).Err(err).
4545
Stringer("lid", id).

pkg/connector/startchat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (wa *WhatsAppConnector) ValidateUserID(id networkid.UserID) bool {
109109

110110
func (wa *WhatsAppClient) startChatLIDToPN(ctx context.Context, jid types.JID) (types.JID, error) {
111111
if jid.Server == types.HiddenUserServer {
112-
pn, err := wa.Device.LIDs.GetPNForLID(ctx, jid)
112+
pn, err := wa.GetStore().LIDs.GetPNForLID(ctx, jid)
113113
if err != nil {
114114
return jid, fmt.Errorf("failed to get phone number for lid: %w", err)
115115
} else if pn.IsEmpty() {

pkg/connector/userinfo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ func (wa *WhatsAppClient) syncAltGhostWithInfo(ctx context.Context, jid types.JI
378378
var altJID types.JID
379379
var err error
380380
if jid.Server == types.HiddenUserServer {
381-
altJID, err = wa.Device.LIDs.GetPNForLID(ctx, jid)
381+
altJID, err = wa.GetStore().LIDs.GetPNForLID(ctx, jid)
382382
} else if jid.Server == types.DefaultUserServer {
383-
altJID, err = wa.Device.LIDs.GetLIDForPN(ctx, jid)
383+
altJID, err = wa.GetStore().LIDs.GetLIDForPN(ctx, jid)
384384
}
385385
if err != nil {
386386
log.Warn().Err(err).

0 commit comments

Comments
 (0)