Skip to content

Commit

Permalink
switch to added by inbox id
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed May 29, 2024
1 parent cb316e4 commit ae5ac8c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ test('who added me to a group', async () => {

await boClient.conversations.syncGroups()
const boGroup = (await boClient.conversations.listGroups())[0]
const addedByAddress = await boGroup.addedByAddress()
const addedByInboxId = await boGroup.addedByInboxId()

assert(
addedByAddress.toLocaleLowerCase === alixClient.address.toLocaleLowerCase,
`addedByAddress ${addedByAddress} does not match ${alixClient.address}`
addedByInboxId === alixClient.inboxId,
`addedByInboxId ${addedByInboxId} does not match ${alixClient.inboxId}`
)
return true
})
Expand Down
4 changes: 2 additions & 2 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,12 @@ public class XMTPModule: Module {
return try group.isActive()
}

AsyncFunction("addedByAddress") { (clientAddress: String, id: String) -> String in
AsyncFunction("addedByInboxId") { (clientAddress: String, id: String) -> String in
guard let group = try await findGroup(clientAddress: clientAddress, id: id) else {
throw Error.conversationNotFound("no group found for \(id)")
}

return try group.addedByAddress()
return try group.addedByInboxId()
}

AsyncFunction("isGroupAdmin") { (clientAddress: String, id: String) -> Bool in
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,11 @@ export async function isGroupActive(
return XMTPModule.isGroupActive(clientAddress, id)
}

export async function addedByAddress(
export async function addedByInboxId(
clientAddress: string,
id: string
): Promise<string> {
return XMTPModule.addedByAddress(clientAddress, id)
return XMTPModule.addedByInboxId(clientAddress, id)
}

export async function isGroupAdmin(
Expand Down
16 changes: 14 additions & 2 deletions src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ export class Group<
return XMTP.removeGroupMembers(this.client.address, this.id, addresses)
}

async addMembersByInboxId(inboxIds: string[]): Promise<void> {
return XMTP.addGroupMembersByInboxId(this.client.address, this.id, inboxIds)
}

async removeMembersByInboxId(inboxIds: string[]): Promise<void> {
return XMTP.removeGroupMembersByInboxId(
this.client.address,
this.id,
inboxIds
)
}

// Returns the group name.
// To get the latest group name from the network, call sync() first.
async groupName(): Promise<string> {
Expand All @@ -197,8 +209,8 @@ export class Group<

// Returns the address that added you to the group.
// To get the latest added by address from the network, call sync() first.
async addedByAddress(): Promise<string> {
return XMTP.addedByAddress(this.client.address, this.id)
async addedByInboxId(): Promise<string> {
return XMTP.addedByInboxId(this.client.address, this.id)
}

// Returns whether you are an admin of the group.
Expand Down

0 comments on commit ae5ac8c

Please sign in to comment.