Skip to content

Commit a39d89c

Browse files
committed
handlematrix: allow resyncing DM portals on viewing chat event
1 parent c2c98f2 commit a39d89c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

pkg/connector/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ func (wa *WhatsAppClient) HandleMatrixViewingChat(ctx context.Context, msg *brid
423423
// Reset, but don't save, portal last sync time for immediate sync now
424424
msg.Portal.Metadata.(*waid.PortalMetadata).LastSync.Time = time.Time{}
425425
// Enqueue for the sync, don't block on it completing
426-
wa.EnqueuePortalResync(msg.Portal)
426+
wa.EnqueuePortalResync(msg.Portal, true)
427427

428428
if msg.Portal.OtherUserID != "" {
429429
// If this is a DM, also sync the ghost of the other user immediately

pkg/connector/events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (evt *WAMessageEvent) HandleExisting(ctx context.Context, portal *bridgev2.
263263
}
264264

265265
func (evt *WAMessageEvent) ConvertMessage(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI) (*bridgev2.ConvertedMessage, error) {
266-
evt.wa.EnqueuePortalResync(portal)
266+
evt.wa.EnqueuePortalResync(portal, false)
267267
converted := evt.wa.Main.MsgConv.ToMatrix(
268268
ctx, portal, evt.wa.Client, intent, evt.Message, evt.MsgEvent.RawMessage, &evt.Info, evt.isViewOnce(), false, nil,
269269
)

pkg/connector/userinfo.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ func (wa *WhatsAppClient) EnqueueGhostResync(ghost *bridgev2.Ghost) {
4848
wa.resyncQueueLock.Unlock()
4949
}
5050

51-
func (wa *WhatsAppClient) EnqueuePortalResync(portal *bridgev2.Portal) {
51+
func (wa *WhatsAppClient) EnqueuePortalResync(portal *bridgev2.Portal, allowDM bool) {
5252
jid, _ := waid.ParsePortalID(portal.ID)
53-
if jid.Server != types.GroupServer || portal.Metadata.(*waid.PortalMetadata).LastSync.Add(ResyncMinInterval).After(time.Now()) {
53+
if portal.Metadata.(*waid.PortalMetadata).LastSync.Add(ResyncMinInterval).After(time.Now()) {
54+
return
55+
} else if !allowDM && jid.Server != types.GroupServer {
5456
return
5557
}
5658
wa.resyncQueueLock.Lock()

0 commit comments

Comments
 (0)