@@ -522,22 +522,12 @@ func (cli *Client) MarkNotDirty(ctx context.Context, cleanType string, ts time.T
522522 return err
523523}
524524
525- func (cli * Client ) SendFatalAppStateExceptionNotification (ctx context.Context , collections ... appstate.WAPatchName ) (SendResponse , error ) {
526- if len (collections ) == 0 {
527- return SendResponse {}, nil
528- }
529- return cli .SendMessage (
530- ctx ,
531- cli .getOwnID ().ToNonAD (),
532- BuildFatalAppStateExceptionNotification (collections ... ),
533- SendRequestExtra {Peer : true },
534- )
535- }
536-
525+ // BuildFatalAppStateExceptionNotification builds a message to request the user's primary device
526+ // to reset specific app state collections. This will cause all linked devices to be logged out.
527+ //
528+ // The built message can be sent using Client.SendPeerMessage.
529+ // There is no response, as the client will get logged out.
537530func BuildFatalAppStateExceptionNotification (collections ... appstate.WAPatchName ) * waE2E.Message {
538- if len (collections ) == 0 {
539- return nil
540- }
541531 return & waE2E.Message {
542532 ProtocolMessage : & waE2E.ProtocolMessage {
543533 Type : waE2E .ProtocolMessage_APP_STATE_FATAL_EXCEPTION_NOTIFICATION .Enum (),
@@ -548,3 +538,23 @@ func BuildFatalAppStateExceptionNotification(collections ...appstate.WAPatchName
548538 },
549539 }
550540}
541+
542+ // BuildAppStateRecoveryRequest builds a message to request the user's primary device to send
543+ // an unencrypted copy of the given app state collection.
544+ //
545+ // The built message can be sent using Client.SendPeerMessage.
546+ // The response will come as a ProtocolMessage with type `PEER_DATA_OPERATION_RESPONSE_MESSAGE`.
547+ func BuildAppStateRecoveryRequest (collection appstate.WAPatchName ) * waE2E.Message {
548+ return & waE2E.Message {
549+ ProtocolMessage : & waE2E.ProtocolMessage {
550+ Type : waE2E .ProtocolMessage_PEER_DATA_OPERATION_REQUEST_MESSAGE .Enum (),
551+ PeerDataOperationRequestMessage : & waE2E.PeerDataOperationRequestMessage {
552+ PeerDataOperationRequestType : waE2E .PeerDataOperationRequestType_COMPANION_SYNCD_SNAPSHOT_FATAL_RECOVERY .Enum (),
553+ SyncdCollectionFatalRecoveryRequest : & waE2E.PeerDataOperationRequestMessage_SyncDCollectionFatalRecoveryRequest {
554+ CollectionName : (* string )(& collection ),
555+ Timestamp : ptr .Ptr (time .Now ().Unix ()),
556+ },
557+ },
558+ },
559+ }
560+ }
0 commit comments