mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2,event: add interface for message requests
This commit is contained in:
parent
e7a95b7f97
commit
31579be20a
13 changed files with 173 additions and 77 deletions
|
|
@ -89,7 +89,11 @@ type BeeperRoomKeyAckEventContent struct {
|
|||
}
|
||||
|
||||
type BeeperChatDeleteEventContent struct {
|
||||
DeleteForEveryone bool `json:"delete_for_everyone,omitempty"`
|
||||
DeleteForEveryone bool `json:"delete_for_everyone,omitempty"`
|
||||
FromMessageRequest bool `json:"from_message_request,omitempty"`
|
||||
}
|
||||
|
||||
type BeeperAcceptMessageRequestEventContent struct {
|
||||
}
|
||||
|
||||
type BeeperSendStateEventContent struct {
|
||||
|
|
|
|||
5
event/capabilities.d.ts
vendored
5
event/capabilities.d.ts
vendored
|
|
@ -77,6 +77,11 @@ export interface RoomFeatures {
|
|||
delete_chat?: boolean
|
||||
/** Whether deleting the chat for all participants is supported. */
|
||||
delete_chat_for_everyone?: boolean
|
||||
/** What can be done with message requests? */
|
||||
message_request?: {
|
||||
accept_with_message?: CapabilitySupportLevel
|
||||
accept_with_button?: CapabilitySupportLevel
|
||||
}
|
||||
}
|
||||
|
||||
declare type integer = number
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ type RoomFeatures struct {
|
|||
DeleteChat bool `json:"delete_chat,omitempty"`
|
||||
DeleteChatForEveryone bool `json:"delete_chat_for_everyone,omitempty"`
|
||||
|
||||
MessageRequest *MessageRequestFeatures `json:"message_request,omitempty"`
|
||||
|
||||
PerMessageProfileRelay bool `json:"-"`
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +86,7 @@ func (rf *RoomFeatures) Clone() *RoomFeatures {
|
|||
clone.DeleteMaxAge = ptr.Clone(clone.DeleteMaxAge)
|
||||
clone.DisappearingTimer = clone.DisappearingTimer.Clone()
|
||||
clone.AllowedReactions = slices.Clone(clone.AllowedReactions)
|
||||
clone.MessageRequest = clone.MessageRequest.Clone()
|
||||
return &clone
|
||||
}
|
||||
|
||||
|
|
@ -165,6 +168,25 @@ func (dtc *DisappearingTimerCapability) Supports(content *BeeperDisappearingTime
|
|||
return slices.Contains(dtc.Types, content.Type) && (dtc.Timers == nil || slices.Contains(dtc.Timers, content.Timer))
|
||||
}
|
||||
|
||||
type MessageRequestFeatures struct {
|
||||
AcceptWithMessage CapabilitySupportLevel `json:"accept_with_message,omitempty"`
|
||||
AcceptWithButton CapabilitySupportLevel `json:"accept_with_button,omitempty"`
|
||||
}
|
||||
|
||||
func (mrf *MessageRequestFeatures) Clone() *MessageRequestFeatures {
|
||||
return ptr.Clone(mrf)
|
||||
}
|
||||
|
||||
func (mrf *MessageRequestFeatures) Hash() []byte {
|
||||
if mrf == nil {
|
||||
return nil
|
||||
}
|
||||
hasher := sha256.New()
|
||||
hashValue(hasher, "accept_with_message", mrf.AcceptWithMessage)
|
||||
hashValue(hasher, "accept_with_button", mrf.AcceptWithButton)
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
||||
type CapabilityMsgType = MessageType
|
||||
|
||||
// Message types which are used for event capability signaling, but aren't real values for the msgtype field.
|
||||
|
|
@ -347,6 +369,7 @@ func (rf *RoomFeatures) Hash() []byte {
|
|||
hashBool(hasher, "mark_as_unread", rf.MarkAsUnread)
|
||||
hashBool(hasher, "delete_chat", rf.DeleteChat)
|
||||
hashBool(hasher, "delete_chat_for_everyone", rf.DeleteChatForEveryone)
|
||||
hashValue(hasher, "message_request", rf.MessageRequest)
|
||||
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,10 +61,11 @@ var TypeMap = map[Type]reflect.Type{
|
|||
EventUnstablePollStart: reflect.TypeOf(PollStartEventContent{}),
|
||||
EventUnstablePollResponse: reflect.TypeOf(PollResponseEventContent{}),
|
||||
|
||||
BeeperMessageStatus: reflect.TypeOf(BeeperMessageStatusEventContent{}),
|
||||
BeeperTranscription: reflect.TypeOf(BeeperTranscriptionEventContent{}),
|
||||
BeeperDeleteChat: reflect.TypeOf(BeeperChatDeleteEventContent{}),
|
||||
BeeperSendState: reflect.TypeOf(BeeperSendStateEventContent{}),
|
||||
BeeperMessageStatus: reflect.TypeOf(BeeperMessageStatusEventContent{}),
|
||||
BeeperTranscription: reflect.TypeOf(BeeperTranscriptionEventContent{}),
|
||||
BeeperDeleteChat: reflect.TypeOf(BeeperChatDeleteEventContent{}),
|
||||
BeeperAcceptMessageRequest: reflect.TypeOf(BeeperAcceptMessageRequestEventContent{}),
|
||||
BeeperSendState: reflect.TypeOf(BeeperSendStateEventContent{}),
|
||||
|
||||
AccountDataRoomTags: reflect.TypeOf(TagEventContent{}),
|
||||
AccountDataDirectChats: reflect.TypeOf(DirectChatsEventContent{}),
|
||||
|
|
|
|||
|
|
@ -231,7 +231,8 @@ type BridgeInfoSection struct {
|
|||
AvatarURL id.ContentURIString `json:"avatar_url,omitempty"`
|
||||
ExternalURL string `json:"external_url,omitempty"`
|
||||
|
||||
Receiver string `json:"fi.mau.receiver,omitempty"`
|
||||
Receiver string `json:"fi.mau.receiver,omitempty"`
|
||||
MessageRequest bool `json:"com.beeper.message_request,omitempty"`
|
||||
}
|
||||
|
||||
// BridgeEventContent represents the content of a m.bridge state event.
|
||||
|
|
|
|||
|
|
@ -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, BeeperDeleteChat.Type:
|
||||
EventUnstablePollEnd.Type, BeeperTranscription.Type, BeeperDeleteChat.Type, BeeperAcceptMessageRequest.Type:
|
||||
return MessageEventType
|
||||
case ToDeviceRoomKey.Type, ToDeviceRoomKeyRequest.Type, ToDeviceForwardedRoomKey.Type, ToDeviceRoomKeyWithheld.Type,
|
||||
ToDeviceBeeperRoomKeyAck.Type:
|
||||
|
|
@ -234,10 +234,11 @@ var (
|
|||
CallNegotiate = Type{"m.call.negotiate", MessageEventType}
|
||||
CallHangup = Type{"m.call.hangup", MessageEventType}
|
||||
|
||||
BeeperMessageStatus = Type{"com.beeper.message_send_status", MessageEventType}
|
||||
BeeperTranscription = Type{"com.beeper.transcription", MessageEventType}
|
||||
BeeperDeleteChat = Type{"com.beeper.delete_chat", MessageEventType}
|
||||
BeeperSendState = Type{"com.beeper.send_state", MessageEventType}
|
||||
BeeperMessageStatus = Type{"com.beeper.message_send_status", MessageEventType}
|
||||
BeeperTranscription = Type{"com.beeper.transcription", MessageEventType}
|
||||
BeeperDeleteChat = Type{"com.beeper.delete_chat", MessageEventType}
|
||||
BeeperAcceptMessageRequest = Type{"com.beeper.accept_message_request", MessageEventType}
|
||||
BeeperSendState = Type{"com.beeper.send_state", MessageEventType}
|
||||
|
||||
EventUnstablePollStart = Type{Type: "org.matrix.msc3381.poll.start", Class: MessageEventType}
|
||||
EventUnstablePollResponse = Type{Type: "org.matrix.msc3381.poll.response", Class: MessageEventType}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue