From b3c883bc7fa39021bf8cfde6d51ce5860b8dded5 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 22 Sep 2025 16:05:28 +0300 Subject: [PATCH] event: add beeper chat delete event --- event/beeper.go | 4 ++++ event/capabilities.d.ts | 5 +++++ event/capabilities.go | 12 +++++++----- event/content.go | 1 + event/type.go | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/event/beeper.go b/event/beeper.go index 921e3466..95b4a571 100644 --- a/event/beeper.go +++ b/event/beeper.go @@ -86,6 +86,10 @@ type BeeperRoomKeyAckEventContent struct { FirstMessageIndex int `json:"first_message_index"` } +type BeeperChatDeleteEventContent struct { + DeleteForEveryone bool `json:"delete_for_everyone,omitempty"` +} + type IntOrString int func (ios *IntOrString) UnmarshalJSON(data []byte) error { diff --git a/event/capabilities.d.ts b/event/capabilities.d.ts index 27164a5f..37848575 100644 --- a/event/capabilities.d.ts +++ b/event/capabilities.d.ts @@ -55,6 +55,11 @@ export interface RoomFeatures { allowed_reactions?: string[] /** Whether custom emoji reactions are allowed. */ custom_emoji_reactions?: boolean + + /** Whether deleting the chat for yourself is supported. */ + delete_chat?: boolean + /** Whether deleting the chat for all participants is supported. */ + delete_chat_for_everyone?: boolean } declare type integer = number diff --git a/event/capabilities.go b/event/capabilities.go index 94662428..31a6b7aa 100644 --- a/event/capabilities.go +++ b/event/capabilities.go @@ -51,11 +51,12 @@ type RoomFeatures struct { AllowedReactions []string `json:"allowed_reactions,omitempty"` CustomEmojiReactions bool `json:"custom_emoji_reactions,omitempty"` - ReadReceipts bool `json:"read_receipts,omitempty"` - TypingNotifications bool `json:"typing_notifications,omitempty"` - Archive bool `json:"archive,omitempty"` - MarkAsUnread bool `json:"mark_as_unread,omitempty"` - DeleteChat bool `json:"delete_chat,omitempty"` + ReadReceipts bool `json:"read_receipts,omitempty"` + TypingNotifications bool `json:"typing_notifications,omitempty"` + Archive bool `json:"archive,omitempty"` + MarkAsUnread bool `json:"mark_as_unread,omitempty"` + DeleteChat bool `json:"delete_chat,omitempty"` + DeleteChatForEveryone bool `json:"delete_chat_for_everyone,omitempty"` } func (rf *RoomFeatures) GetID() string { @@ -262,6 +263,7 @@ func (rf *RoomFeatures) Hash() []byte { hashBool(hasher, "archive", rf.Archive) hashBool(hasher, "mark_as_unread", rf.MarkAsUnread) hashBool(hasher, "delete_chat", rf.DeleteChat) + hashBool(hasher, "delete_chat_for_everyone", rf.DeleteChatForEveryone) return hasher.Sum(nil) } diff --git a/event/content.go b/event/content.go index 5e093273..c0ff51ad 100644 --- a/event/content.go +++ b/event/content.go @@ -63,6 +63,7 @@ var TypeMap = map[Type]reflect.Type{ BeeperMessageStatus: reflect.TypeOf(BeeperMessageStatusEventContent{}), BeeperTranscription: reflect.TypeOf(BeeperTranscriptionEventContent{}), + BeeperDeleteChat: reflect.TypeOf(BeeperChatDeleteEventContent{}), AccountDataRoomTags: reflect.TypeOf(TagEventContent{}), AccountDataDirectChats: reflect.TypeOf(DirectChatsEventContent{}), diff --git a/event/type.go b/event/type.go index 1b4fbf76..56ea82f6 100644 --- a/event/type.go +++ b/event/type.go @@ -128,7 +128,7 @@ func (et *Type) GuessClass() TypeClass { InRoomVerificationKey.Type, InRoomVerificationMAC.Type, InRoomVerificationCancel.Type, CallInvite.Type, CallCandidates.Type, CallAnswer.Type, CallReject.Type, CallSelectAnswer.Type, CallNegotiate.Type, CallHangup.Type, BeeperMessageStatus.Type, EventUnstablePollStart.Type, EventUnstablePollResponse.Type, - EventUnstablePollEnd.Type, BeeperTranscription.Type: + EventUnstablePollEnd.Type, BeeperTranscription.Type, BeeperDeleteChat.Type: return MessageEventType case ToDeviceRoomKey.Type, ToDeviceRoomKeyRequest.Type, ToDeviceForwardedRoomKey.Type, ToDeviceRoomKeyWithheld.Type, ToDeviceBeeperRoomKeyAck.Type: @@ -236,6 +236,7 @@ var ( BeeperMessageStatus = Type{"com.beeper.message_send_status", MessageEventType} BeeperTranscription = Type{"com.beeper.transcription", MessageEventType} + BeeperDeleteChat = Type{"com.beeper.delete_chat", MessageEventType} EventUnstablePollStart = Type{Type: "org.matrix.msc3381.poll.start", Class: MessageEventType} EventUnstablePollResponse = Type{Type: "org.matrix.msc3381.poll.response", Class: MessageEventType}