Skip to content

Commit

Permalink
remove pinned frame url from all the places
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 3, 2025
1 parent 6c593b3 commit 7520037
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ class XMTPModule : Module() {
createGroupParams.groupName,
createGroupParams.groupImageUrlSquare,
createGroupParams.groupDescription,
createGroupParams.groupPinnedFrameUrl
)
GroupWrapper.encode(client, group)
}
Expand All @@ -818,7 +817,6 @@ class XMTPModule : Module() {
createGroupParams.groupName,
createGroupParams.groupImageUrlSquare,
createGroupParams.groupDescription,
createGroupParams.groupPinnedFrameUrl
)
GroupWrapper.encode(client, group)
}
Expand All @@ -840,7 +838,6 @@ class XMTPModule : Module() {
createGroupParams.groupName,
createGroupParams.groupImageUrlSquare,
createGroupParams.groupDescription,
createGroupParams.groupPinnedFrameUrl
)
GroupWrapper.encode(client, group)
}
Expand All @@ -862,7 +859,6 @@ class XMTPModule : Module() {
createGroupParams.groupName,
createGroupParams.groupImageUrlSquare,
createGroupParams.groupDescription,
createGroupParams.groupPinnedFrameUrl
)
GroupWrapper.encode(client, group)
}
Expand Down Expand Up @@ -1028,26 +1024,6 @@ class XMTPModule : Module() {
}
}

AsyncFunction("groupPinnedFrameUrl") Coroutine { installationId: String, groupId: String ->
withContext(Dispatchers.IO) {
logV("groupPinnedFrameUrl")
val client = clients[installationId] ?: throw XMTPException("No client")
val group = client.findGroup(groupId)
?: throw XMTPException("no group found for $groupId")
group.pinnedFrameUrl
}
}

AsyncFunction("updateGroupPinnedFrameUrl") Coroutine { installationId: String, groupId: String, pinnedFrameUrl: String ->
withContext(Dispatchers.IO) {
logV("updateGroupPinnedFrameUrl")
val client = clients[installationId] ?: throw XMTPException("No client")
val group = client.findGroup(groupId)
?: throw XMTPException("no group found for $groupId")
group.updateGroupPinnedFrameUrl(pinnedFrameUrl)
}
}

AsyncFunction("isGroupActive") Coroutine { installationId: String, groupId: String ->
withContext(Dispatchers.IO) {
logV("isGroupActive")
Expand Down Expand Up @@ -1228,16 +1204,6 @@ class XMTPModule : Module() {
}
}

AsyncFunction("updateGroupPinnedFrameUrlPermission") Coroutine { clientInstallationId: String, groupId: String, newPermission: String ->
withContext(Dispatchers.IO) {
logV("updateGroupPinnedFrameUrlPermission")
val client = clients[clientInstallationId] ?: throw XMTPException("No client")
val group = client.findGroup(groupId)
?: throw XMTPException("no group found for $groupId")
group.updateGroupPinnedFrameUrlPermission(getPermissionOption(newPermission))
}
}

AsyncFunction("permissionPolicySet") Coroutine { installationId: String, groupId: String ->
withContext(Dispatchers.IO) {
logV("groupImageUrlSquare")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class CreateGroupParamsWrapper(
val groupName: String,
val groupImageUrlSquare: String,
val groupDescription: String,
val groupPinnedFrameUrl: String,
) {
companion object {
fun createGroupParamsFromJson(authParams: String): CreateGroupParamsWrapper {
Expand All @@ -15,7 +14,6 @@ class CreateGroupParamsWrapper(
if (jsonOptions.has("name")) jsonOptions.get("name").asString else "",
if (jsonOptions.has("imageUrlSquare")) jsonOptions.get("imageUrlSquare").asString else "",
if (jsonOptions.has("description")) jsonOptions.get("description").asString else "",
if (jsonOptions.has("pinnedFrameUrl")) jsonOptions.get("pinnedFrameUrl").asString else "",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class PermissionPolicySetWrapper {
"updateGroupNamePolicy" to fromPermissionOption(policySet.updateGroupNamePolicy),
"updateGroupDescriptionPolicy" to fromPermissionOption(policySet.updateGroupDescriptionPolicy),
"updateGroupImagePolicy" to fromPermissionOption(policySet.updateGroupImagePolicy),
"updateGroupPinnedFrameUrlPolicy" to fromPermissionOption(policySet.updateGroupPinnedFrameUrlPolicy),
"updateMessageExpirationPolicy" to fromPermissionOption(policySet.updateMessageExpirationPolicy),
)
}
Expand All @@ -51,7 +50,6 @@ class PermissionPolicySetWrapper {
updateGroupNamePolicy = createPermissionOptionFromString(jsonObj.get("updateGroupNamePolicy").asString),
updateGroupDescriptionPolicy = createPermissionOptionFromString(jsonObj.get("updateGroupDescriptionPolicy").asString),
updateGroupImagePolicy = createPermissionOptionFromString(jsonObj.get("updateGroupImagePolicy").asString),
updateGroupPinnedFrameUrlPolicy = createPermissionOptionFromString(jsonObj.get("updateGroupPinnedFrameUrlPolicy").asString),
updateMessageExpirationPolicy = createPermissionOptionFromString(jsonObj.get("updateMessageExpirationPolicy").asString),
)
}
Expand Down
1 change: 0 additions & 1 deletion example/src/tests/groupPerformanceTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ test('creating a new conversation', async () => {
name: 'Group Name',
imageUrlSquare: 'imageurl.com',
description: 'group description',
pinnedFrameUrl: 'pinnedframe.com',
}
)
const end4 = performance.now()
Expand Down
66 changes: 0 additions & 66 deletions example/src/tests/groupPermissionsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,56 +468,6 @@ test('can update group permissions', async () => {
return true
})

test('can update group pinned frame', async () => {
// Create clients
const [alix, bo, caro] = await createClients(3)

// Bo creates a group with Alix and Caro
const boGroup = await bo.conversations.newGroup(
[alix.address, caro.address],
{ permissionLevel: 'admin_only' }
)

// Verify that alix can not update the group pinned frame
await alix.conversations.sync()
const alixGroup = (await alix.conversations.listGroups())[0]
try {
await alixGroup.updateGroupPinnedFrameUrl('new pinned frame')
return false
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
// expected
}

// Verify that bo can update the group pinned frame
await boGroup.updateGroupPinnedFrameUrl('new pinned frame 2')
await boGroup.sync()
assert(
(await boGroup.groupPinnedFrameUrl()) === 'new pinned frame 2',
`boGroup.groupPinnedFrameUrl should be "new pinned frame 2" but was ${boGroup.groupPinnedFrameUrl}`
)

// Verify that bo can update the pinned frame permission
await boGroup.updateGroupPinnedFrameUrlPermission('allow')
await boGroup.sync()
assert(
(await boGroup.permissionPolicySet()).updateGroupPinnedFrameUrlPolicy ===
'allow',
`boGroup.permissionPolicySet.updateGroupPinnedFrameUrlPolicy should be allow but was ${(await boGroup.permissionPolicySet()).updateGroupPinnedFrameUrlPolicy}`
)

// Verify that Alix can now update pinned frames
await alixGroup.updateGroupPinnedFrameUrl('new pinned frame 3')
await alixGroup.sync()
await boGroup.sync()
assert(
(await boGroup.groupPinnedFrameUrl()) === 'new pinned frame 3',
`alixGroup.groupPinnedFrameUrl should be "new pinned frame 3" but was ${boGroup.groupPinnedFrameUrl}`
)

return true
})

test('can create a group with custom permissions', async () => {
// Create clients
const [alix, bo, caro] = await createClients(3)
Expand All @@ -530,7 +480,6 @@ test('can create a group with custom permissions', async () => {
updateGroupNamePolicy: 'admin',
updateGroupDescriptionPolicy: 'allow',
updateGroupImagePolicy: 'admin',
updateGroupPinnedFrameUrlPolicy: 'deny',
updateMessageExpirationPolicy: 'deny',
}

Expand Down Expand Up @@ -577,20 +526,6 @@ test('can create a group with custom permissions', async () => {
customPermissionsPolicySet.updateGroupImagePolicy,
`permissions.updateGroupImagePolicy should be ${customPermissionsPolicySet.updateGroupImagePolicy} but was ${permissions.updateGroupImagePolicy}`
)
assert(
permissions.updateGroupPinnedFrameUrlPolicy ===
customPermissionsPolicySet.updateGroupPinnedFrameUrlPolicy,
`permissions.updateGroupPinnedFrameUrlPolicy should be ${customPermissionsPolicySet.updateGroupPinnedFrameUrlPolicy} but was ${permissions.updateGroupPinnedFrameUrlPolicy}`
)

// Verify that bo can not update the pinned frame even though they are a super admin
try {
await boGroup.updateGroupPinnedFrameUrl('new pinned frame')
return false
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
// expected
}

// Verify that alix can update the group description
await alixGroup.updateGroupDescription('new description')
Expand Down Expand Up @@ -625,7 +560,6 @@ test('creating a group with invalid permissions should fail', async () => {
updateGroupNamePolicy: 'admin',
updateGroupDescriptionPolicy: 'allow',
updateGroupImagePolicy: 'admin',
updateGroupPinnedFrameUrlPolicy: 'deny',
updateMessageExpirationPolicy: 'admin',
}

Expand Down
5 changes: 1 addition & 4 deletions ios/Wrappers/CreateGroupParamsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ struct CreateGroupParamsWrapper {
let groupName: String
let groupImageUrlSquare: String
let groupDescription: String
let groupPinnedFrameUrl: String

static func createGroupParamsFromJson(_ authParams: String) -> CreateGroupParamsWrapper {
let data = authParams.data(using: .utf8) ?? Data()
Expand All @@ -13,13 +12,11 @@ struct CreateGroupParamsWrapper {
let groupName = jsonOptions["name"] as? String ?? ""
let groupImageUrlSquare = jsonOptions["imageUrlSquare"] as? String ?? ""
let groupDescription = jsonOptions["description"] as? String ?? ""
let groupPinnedFrameUrl = jsonOptions["pinnedFrameUrl"] as? String ?? ""

return CreateGroupParamsWrapper(
groupName: groupName,
groupImageUrlSquare: groupImageUrlSquare,
groupDescription: groupDescription,
groupPinnedFrameUrl: groupPinnedFrameUrl
groupDescription: groupDescription
)
}
}
2 changes: 0 additions & 2 deletions ios/Wrappers/PermissionPolicySetWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class PermissionPolicySetWrapper {
"updateGroupNamePolicy": fromPermissionOption(policySet.updateGroupNamePolicy),
"updateGroupDescriptionPolicy": fromPermissionOption(policySet.updateGroupDescriptionPolicy),
"updateGroupImagePolicy": fromPermissionOption(policySet.updateGroupImagePolicy),
"updateGroupPinnedFrameUrlPolicy": fromPermissionOption(policySet.updateGroupPinnedFrameUrlPolicy),
"updateMessageExpirationPolicy": fromPermissionOption(policySet.updateMessageExpirationPolicy)
]
}
Expand All @@ -72,7 +71,6 @@ class PermissionPolicySetWrapper {
updateGroupNamePolicy: createPermissionOption(from: jsonDict["updateGroupNamePolicy"] as? String ?? ""),
updateGroupDescriptionPolicy: createPermissionOption(from: jsonDict["updateGroupDescriptionPolicy"] as? String ?? ""),
updateGroupImagePolicy: createPermissionOption(from: jsonDict["updateGroupImagePolicy"] as? String ?? ""),
updateGroupPinnedFrameUrlPolicy: createPermissionOption(from: jsonDict["updateGroupPinnedFrameUrlPolicy"] as? String ?? ""),
updateMessageExpirationPolicy: createPermissionOption(from: jsonDict["updateMessageExpirationPolicy"] as? String ?? "")
)
}
Expand Down
60 changes: 4 additions & 56 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,7 @@ public class XMTPModule: Module {
permissions: permissionLevel,
name: createGroupParams.groupName,
imageUrlSquare: createGroupParams.groupImageUrlSquare,
description: createGroupParams.groupDescription,
pinnedFrameUrl: createGroupParams.groupPinnedFrameUrl
description: createGroupParams.groupDescription
)
return try await GroupWrapper.encode(group, client: client)
} catch {
Expand Down Expand Up @@ -957,8 +956,7 @@ public class XMTPModule: Module {
permissionPolicySet: permissionPolicySet,
name: createGroupParams.groupName,
imageUrlSquare: createGroupParams.groupImageUrlSquare,
description: createGroupParams.groupDescription,
pinnedFrameUrl: createGroupParams.groupPinnedFrameUrl
description: createGroupParams.groupDescription
)
return try await GroupWrapper.encode(group, client: client)
} catch {
Expand Down Expand Up @@ -995,8 +993,7 @@ public class XMTPModule: Module {
permissions: permissionLevel,
name: createGroupParams.groupName,
imageUrlSquare: createGroupParams.groupImageUrlSquare,
description: createGroupParams.groupDescription,
pinnedFrameUrl: createGroupParams.groupPinnedFrameUrl
description: createGroupParams.groupDescription
)
return try await GroupWrapper.encode(group, client: client)
} catch {
Expand Down Expand Up @@ -1028,8 +1025,7 @@ public class XMTPModule: Module {
permissionPolicySet: permissionPolicySet,
name: createGroupParams.groupName,
imageUrlSquare: createGroupParams.groupImageUrlSquare,
description: createGroupParams.groupDescription,
pinnedFrameUrl: createGroupParams.groupPinnedFrameUrl
description: createGroupParams.groupDescription
)
return try await GroupWrapper.encode(group, client: client)
} catch {
Expand Down Expand Up @@ -1292,37 +1288,6 @@ public class XMTPModule: Module {
groupDescription: description)
}

AsyncFunction("groupPinnedFrameUrl") {
(installationId: String, id: String) -> String in
guard
let client = await clientsManager.getClient(key: installationId)
else {
throw Error.noClient
}
guard let group = try client.findGroup(groupId: id) else {
throw Error.conversationNotFound(
"no conversation found for \(id)")
}

return try group.groupPinnedFrameUrl()
}

AsyncFunction("updateGroupPinnedFrameUrl") {
(installationId: String, id: String, pinnedFrameUrl: String) in
guard
let client = await clientsManager.getClient(key: installationId)
else {
throw Error.noClient
}
guard let group = try client.findGroup(groupId: id) else {
throw Error.conversationNotFound(
"no conversation found for \(id)")
}

try await group.updateGroupPinnedFrameUrl(
groupPinnedFrameUrl: pinnedFrameUrl)
}

AsyncFunction("isGroupActive") {
(installationId: String, id: String) -> Bool in
guard
Expand Down Expand Up @@ -1606,23 +1571,6 @@ public class XMTPModule: Module {
permission: newPermission))
}

AsyncFunction("updateGroupPinnedFrameUrlPermission") {
(clientInstallationId: String, id: String, newPermission: String) in
guard
let client = await clientsManager.getClient(
key: clientInstallationId)
else {
throw Error.noClient
}
guard let group = try client.findGroup(groupId: id) else {
throw Error.conversationNotFound(
"no conversation found for \(id)")
}
try await group.updateGroupPinnedFrameUrlPermission(
newPermissionOption: getPermissionOption(
permission: newPermission))
}

AsyncFunction("permissionPolicySet") {
(installationId: String, id: String) async throws -> String in
guard
Expand Down
Loading

0 comments on commit 7520037

Please sign in to comment.