| 1 |
// Copyright (c) 2021 Tulir Asokan |
| 2 |
// |
| 3 |
// This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
// file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 |
|
| 7 |
package event |
| 8 |
|
| 9 |
import ( |
| 10 |
"maunium.net/go/mautrix/id" |
| 11 |
) |
| 12 |
|
| 13 |
// CanonicalAliasEventContent represents the content of a m.room.canonical_alias state event. |
| 14 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomcanonical_alias |
| 15 |
type CanonicalAliasEventContent struct { |
| 16 |
Alias id.RoomAlias `json:"alias"` |
| 17 |
AltAliases []id.RoomAlias `json:"alt_aliases,omitempty"` |
| 18 |
} |
| 19 |
|
| 20 |
// RoomNameEventContent represents the content of a m.room.name state event. |
| 21 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomname |
| 22 |
type RoomNameEventContent struct { |
| 23 |
Name string `json:"name"` |
| 24 |
} |
| 25 |
|
| 26 |
// RoomAvatarEventContent represents the content of a m.room.avatar state event. |
| 27 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomavatar |
| 28 |
type RoomAvatarEventContent struct { |
| 29 |
URL id.ContentURI `json:"url"` |
| 30 |
Info *FileInfo `json:"info,omitempty"` |
| 31 |
} |
| 32 |
|
| 33 |
// ServerACLEventContent represents the content of a m.room.server_acl state event. |
| 34 |
// https://spec.matrix.org/v1.2/client-server-api/#server-access-control-lists-acls-for-rooms |
| 35 |
type ServerACLEventContent struct { |
| 36 |
Allow []string `json:"allow,omitempty"` |
| 37 |
AllowIPLiterals bool `json:"allow_ip_literals"` |
| 38 |
Deny []string `json:"deny,omitempty"` |
| 39 |
} |
| 40 |
|
| 41 |
// TopicEventContent represents the content of a m.room.topic state event. |
| 42 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomtopic |
| 43 |
type TopicEventContent struct { |
| 44 |
Topic string `json:"topic"` |
| 45 |
} |
| 46 |
|
| 47 |
// TombstoneEventContent represents the content of a m.room.tombstone state event. |
| 48 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomtombstone |
| 49 |
type TombstoneEventContent struct { |
| 50 |
Body string `json:"body"` |
| 51 |
ReplacementRoom id.RoomID `json:"replacement_room"` |
| 52 |
} |
| 53 |
|
| 54 |
// CreateEventContent represents the content of a m.room.create state event. |
| 55 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomcreate |
| 56 |
type CreateEventContent struct { |
| 57 |
Type RoomType `json:"type,omitempty"` |
| 58 |
Creator id.UserID `json:"creator,omitempty"` |
| 59 |
Federate bool `json:"m.federate,omitempty"` |
| 60 |
RoomVersion string `json:"version,omitempty"` |
| 61 |
Predecessor struct { |
| 62 |
RoomID id.RoomID `json:"room_id"` |
| 63 |
EventID id.EventID `json:"event_id"` |
| 64 |
} `json:"predecessor"` |
| 65 |
} |
| 66 |
|
| 67 |
// JoinRule specifies how open a room is to new members. |
| 68 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomjoin_rules |
| 69 |
type JoinRule string |
| 70 |
|
| 71 |
const ( |
| 72 |
JoinRulePublic JoinRule = "public" |
| 73 |
JoinRuleKnock JoinRule = "knock" |
| 74 |
JoinRuleInvite JoinRule = "invite" |
| 75 |
JoinRuleRestricted JoinRule = "restricted" |
| 76 |
JoinRulePrivate JoinRule = "private" |
| 77 |
) |
| 78 |
|
| 79 |
// JoinRulesEventContent represents the content of a m.room.join_rules state event. |
| 80 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomjoin_rules |
| 81 |
type JoinRulesEventContent struct { |
| 82 |
JoinRule JoinRule `json:"join_rule"` |
| 83 |
Allow []JoinRuleAllow `json:"allow,omitempty"` |
| 84 |
} |
| 85 |
|
| 86 |
type JoinRuleAllowType string |
| 87 |
|
| 88 |
const ( |
| 89 |
JoinRuleAllowRoomMembership JoinRuleAllowType = "m.room_membership" |
| 90 |
) |
| 91 |
|
| 92 |
type JoinRuleAllow struct { |
| 93 |
RoomID id.RoomID `json:"room_id"` |
| 94 |
Type JoinRuleAllowType `json:"type"` |
| 95 |
} |
| 96 |
|
| 97 |
// PinnedEventsEventContent represents the content of a m.room.pinned_events state event. |
| 98 |
// https://spec.matrix.org/v1.2/client-server-api/#mroompinned_events |
| 99 |
type PinnedEventsEventContent struct { |
| 100 |
Pinned []id.EventID `json:"pinned"` |
| 101 |
} |
| 102 |
|
| 103 |
// HistoryVisibility specifies who can see new messages. |
| 104 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomhistory_visibility |
| 105 |
type HistoryVisibility string |
| 106 |
|
| 107 |
const ( |
| 108 |
HistoryVisibilityInvited HistoryVisibility = "invited" |
| 109 |
HistoryVisibilityJoined HistoryVisibility = "joined" |
| 110 |
HistoryVisibilityShared HistoryVisibility = "shared" |
| 111 |
HistoryVisibilityWorldReadable HistoryVisibility = "world_readable" |
| 112 |
) |
| 113 |
|
| 114 |
// HistoryVisibilityEventContent represents the content of a m.room.history_visibility state event. |
| 115 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomhistory_visibility |
| 116 |
type HistoryVisibilityEventContent struct { |
| 117 |
HistoryVisibility HistoryVisibility `json:"history_visibility"` |
| 118 |
} |
| 119 |
|
| 120 |
// GuestAccess specifies whether or not guest accounts can join. |
| 121 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomguest_access |
| 122 |
type GuestAccess string |
| 123 |
|
| 124 |
const ( |
| 125 |
GuestAccessCanJoin GuestAccess = "can_join" |
| 126 |
GuestAccessForbidden GuestAccess = "forbidden" |
| 127 |
) |
| 128 |
|
| 129 |
// GuestAccessEventContent represents the content of a m.room.guest_access state event. |
| 130 |
// https://spec.matrix.org/v1.2/client-server-api/#mroomguest_access |
| 131 |
type GuestAccessEventContent struct { |
| 132 |
GuestAccess GuestAccess `json:"guest_access"` |
| 133 |
} |
| 134 |
|
| 135 |
type BridgeInfoSection struct { |
| 136 |
ID string `json:"id"` |
| 137 |
DisplayName string `json:"displayname,omitempty"` |
| 138 |
AvatarURL id.ContentURIString `json:"avatar_url,omitempty"` |
| 139 |
ExternalURL string `json:"external_url,omitempty"` |
| 140 |
} |
| 141 |
|
| 142 |
// BridgeEventContent represents the content of a m.bridge state event. |
| 143 |
// https://github.com/matrix-org/matrix-doc/pull/2346 |
| 144 |
type BridgeEventContent struct { |
| 145 |
BridgeBot id.UserID `json:"bridgebot"` |
| 146 |
Creator id.UserID `json:"creator,omitempty"` |
| 147 |
Protocol BridgeInfoSection `json:"protocol"` |
| 148 |
Network *BridgeInfoSection `json:"network,omitempty"` |
| 149 |
Channel BridgeInfoSection `json:"channel"` |
| 150 |
} |
| 151 |
|
| 152 |
type SpaceChildEventContent struct { |
| 153 |
Via []string `json:"via,omitempty"` |
| 154 |
Order string `json:"order,omitempty"` |
| 155 |
} |
| 156 |
|
| 157 |
type SpaceParentEventContent struct { |
| 158 |
Via []string `json:"via,omitempty"` |
| 159 |
Canonical bool `json:"canonical,omitempty"` |
| 160 |
} |
| 161 |
|
| 162 |
// ModPolicyContent represents the content of a m.room.rule.user, m.room.rule.room, and m.room.rule.server state event. |
| 163 |
// https://spec.matrix.org/v1.2/client-server-api/#moderation-policy-lists |
| 164 |
type ModPolicyContent struct { |
| 165 |
Entity string `json:"entity"` |
| 166 |
Reason string `json:"reason"` |
| 167 |
Recommendation string `json:"recommendation"` |
| 168 |
} |