Watch
1
0
Fork
You've already forked mautrix-whatsapp
0
mirror of https://github.com/mautrix/whatsapp.git synced 2026-11-09 23:59:17 -05:00

Compare commits

...
Author SHA1 Message Date
Gerardo Rodriguez
52f7da12b2 client: ignore DangerousInternals deprecation for unified_session 2026-10-24 11:12:55 +00:00
Gerardo Rodriguez
7f843e8f12 handlematrix: send unified_session daily on outgoing messages 2026-10-24 11:02:54 +00:00
2 changed files with 11 additions and 0 deletions

View file

@ -124,6 +124,7 @@ type WhatsAppClient struct {
isNewLogin bool isNewLogin bool
pushNamesSynced *exsync.Event pushNamesSynced *exsync.Event
lastPresence types.Presence lastPresence types.Presence
lastUnifiedSession atomic.Int64
blocklistLock sync.Mutex blocklistLock sync.Mutex
disableNewsletter bool disableNewsletter bool
@ -511,6 +512,15 @@ func (wa *WhatsAppClient) updatePresence(ctx context.Context, presence types.Pre
return err return err
} }
func (wa *WhatsAppClient) sendDailyUnifiedSession() {
last := wa.lastUnifiedSession.Load()
if time.Since(time.Unix(last, 0)) < 24*time.Hour || !wa.lastUnifiedSession.CompareAndSwap(last, time.Now().Unix()) {
return
}
//lint:ignore SA1019 this is supposed to be dangerous
go wa.Client.DangerousInternals().SendUnifiedSession()
}
func (wa *WhatsAppClient) DownloadImagePack(ctx context.Context, url string) (*bridgev2.ImportedImagePack, error) { func (wa *WhatsAppClient) DownloadImagePack(ctx context.Context, url string) (*bridgev2.ImportedImagePack, error) {
return wa.Main.MsgConv.DownloadImagePack(ctx, wa.UserLogin.ID, wa.Client, url) return wa.Main.MsgConv.DownloadImagePack(ctx, wa.UserLogin.ID, wa.Client, url)
} }

View file

@ -141,6 +141,7 @@ func (wa *WhatsAppClient) handleConvertedMatrixMessage(ctx context.Context, msg
} }
return nil, wrapWhatsAppError(err) return nil, wrapWhatsAppError(err)
} }
wa.sendDailyUnifiedSession()
var pickedMessageID networkid.MessageID var pickedMessageID networkid.MessageID
if resp.Sender == wa.GetLID() { if resp.Sender == wa.GetLID() {
pickedMessageID = wrappedMsgID2 pickedMessageID = wrappedMsgID2