-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathGroup.ts
115 lines (93 loc) · 2.65 KB
/
Group.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import type {
Identifier,
Message,
MetadataField,
PermissionPolicy,
PermissionUpdateType,
Conversation as XmtpConversation,
} from "@xmtp/node-bindings";
import type { Client } from "@/Client";
import { Conversation } from "@/Conversation";
export class Group extends Conversation {
#conversation: XmtpConversation;
constructor(
client: Client,
conversation: XmtpConversation,
lastMessage?: Message | null,
) {
super(client, conversation, lastMessage);
this.#conversation = conversation;
}
get name() {
return this.#conversation.groupName();
}
async updateName(name: string) {
return this.#conversation.updateGroupName(name);
}
get imageUrl() {
return this.#conversation.groupImageUrlSquare();
}
async updateImageUrl(imageUrl: string) {
return this.#conversation.updateGroupImageUrlSquare(imageUrl);
}
get description() {
return this.#conversation.groupDescription();
}
async updateDescription(description: string) {
return this.#conversation.updateGroupDescription(description);
}
get permissions() {
const permissions = this.#conversation.groupPermissions();
return {
policyType: permissions.policyType(),
policySet: permissions.policySet(),
};
}
async updatePermission(
permissionType: PermissionUpdateType,
policy: PermissionPolicy,
metadataField?: MetadataField,
) {
return this.#conversation.updatePermissionPolicy(
permissionType,
policy,
metadataField,
);
}
get admins() {
return this.#conversation.adminList();
}
get superAdmins() {
return this.#conversation.superAdminList();
}
isAdmin(inboxId: string) {
return this.#conversation.isAdmin(inboxId);
}
isSuperAdmin(inboxId: string) {
return this.#conversation.isSuperAdmin(inboxId);
}
async addMembersByIdentifiers(identifiers: Identifier[]) {
return this.#conversation.addMembers(identifiers);
}
async addMembers(inboxIds: string[]) {
return this.#conversation.addMembersByInboxId(inboxIds);
}
async removeMembersByIdentifiers(identifiers: Identifier[]) {
return this.#conversation.removeMembers(identifiers);
}
async removeMembers(inboxIds: string[]) {
return this.#conversation.removeMembersByInboxId(inboxIds);
}
async addAdmin(inboxId: string) {
return this.#conversation.addAdmin(inboxId);
}
async removeAdmin(inboxId: string) {
return this.#conversation.removeAdmin(inboxId);
}
async addSuperAdmin(inboxId: string) {
return this.#conversation.addSuperAdmin(inboxId);
}
async removeSuperAdmin(inboxId: string) {
return this.#conversation.removeSuperAdmin(inboxId);
}
}