Skip to content

Commit

Permalink
expose it throught the methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jun 3, 2024
1 parent db6b566 commit 3e4aea4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from './lib/ConversationContainer'
import { DecodedMessage, MessageDeliveryStatus } from './lib/DecodedMessage'
import { Group } from './lib/Group'
import { Member } from './lib/Member'
import type { Query } from './lib/Query'
import { ConversationSendPayload } from './lib/types'
import { DefaultContentTypes } from './lib/types/DefaultContentType'
Expand Down Expand Up @@ -147,6 +148,17 @@ export async function listMemberInboxIds<
return XMTPModule.listMemberInboxIds(client.address, id)
}

export async function listGroupMembers(
clientAddress: string,
id: string
): Promise<Member[]> {
const members = await XMTPModule.listGroupMembers(clientAddress, id)

return members.map((json: string) => {
return Member.from(json)
})
}

export async function sendMessageToGroup(
clientAddress: string,
groupId: string,
Expand Down Expand Up @@ -893,3 +905,4 @@ export { Query } from './lib/Query'
export { XMTPPush } from './lib/XMTPPush'
export { ConsentListEntry, DecodedMessage, MessageDeliveryStatus }
export { Group } from './lib/Group'
export { Member } from './lib/Member'
5 changes: 5 additions & 0 deletions src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ConversationContainer,
} from './ConversationContainer'
import { DecodedMessage, MessageDeliveryStatus } from './DecodedMessage'
import { Member } from './Member'
import { ConversationSendPayload } from './types/ConversationCodecs'
import { DefaultContentTypes } from './types/DefaultContentType'
import { EventTypes } from './types/EventTypes'
Expand Down Expand Up @@ -295,4 +296,8 @@ export class Group<
async isDenied(): Promise<boolean> {
return await XMTP.isGroupDenied(this.client.address, this.id)
}

async members(): Promise<Member[]> {
return await XMTP.listGroupMembers(this.client.address, this.id)
}
}
20 changes: 20 additions & 0 deletions src/lib/Member.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export class Member {
inboxId: string
addresses: string[]
permissionLevel: 'member' | 'admin' | 'super_admin'

constructor(
inboxId: string,
addresses: string[],
permissionLevel: 'member' | 'admin' | 'super_admin'
) {
this.inboxId = inboxId
this.addresses = addresses
this.permissionLevel = permissionLevel
}

static from(json: string): Member {
const entry = JSON.parse(json)
return new Member(entry.inboxId, entry.addresses, entry.permissionLevel)
}
}

0 comments on commit 3e4aea4

Please sign in to comment.