Skip to content

Commit

Permalink
Add support for custom permissions policy (node)
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Dec 16, 2024
1 parent 2e83c7a commit cbfeb2a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sdks/node-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@xmtp/content-type-group-updated": "^2.0.0",
"@xmtp/content-type-primitives": "^2.0.0",
"@xmtp/content-type-text": "^2.0.0",
"@xmtp/node-bindings": "^0.0.28",
"@xmtp/node-bindings": "^0.0.29",
"@xmtp/proto": "^3.72.3"
},
"devDependencies": {
Expand Down
37 changes: 37 additions & 0 deletions sdks/node-sdk/test/Conversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,43 @@ describe("Conversations", () => {
expect(groupWithPinnedFrameUrl.pinnedFrameUrl).toBe("https://foo/bar");
});

it("should create a group with custom permissions", async () => {
const user1 = createUser();
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
await createRegisteredClient(user2);
const group = await client1.conversations.newGroup(
[user2.account.address],
{
permissions: GroupPermissionsOptions.CustomPolicy,
customPermissionPolicySet: {
addAdminPolicy: 1,
addMemberPolicy: 0,
removeAdminPolicy: 1,
removeMemberPolicy: 1,
updateGroupNamePolicy: 1,
updateGroupDescriptionPolicy: 1,
updateGroupImageUrlSquarePolicy: 1,
updateGroupPinnedFrameUrlPolicy: 1,
},
},
);
expect(group).toBeDefined();
expect(group.permissions.policyType).toBe(
GroupPermissionsOptions.CustomPolicy,
);
expect(group.permissions.policySet).toEqual({
addAdminPolicy: 1,
addMemberPolicy: 0,
removeAdminPolicy: 1,
removeMemberPolicy: 1,
updateGroupNamePolicy: 1,
updateGroupDescriptionPolicy: 1,
updateGroupImageUrlSquarePolicy: 1,
updateGroupPinnedFrameUrlPolicy: 1,
});
});

it("should stream new conversations", async () => {
const user1 = createUser();
const user2 = createUser();
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5107,10 +5107,10 @@ __metadata:
languageName: unknown
linkType: soft

"@xmtp/node-bindings@npm:^0.0.28":
version: 0.0.28
resolution: "@xmtp/node-bindings@npm:0.0.28"
checksum: 10/0ceea72582926dcce03c8e3839b7101d7ce4aef56a55b46421c2e46e96f65c90a224b1649ff765c1f3cb1e2e21a730d1891bb369260c94712066b85d358fb6f4
"@xmtp/node-bindings@npm:^0.0.29":
version: 0.0.29
resolution: "@xmtp/node-bindings@npm:0.0.29"
checksum: 10/d6abb86a58517bffff07bda59b387318a9d60b2ba0ca13376ef60fe79aa9afefb8e2b07b218064738b07c4e699eac967f8aff64942017f8872f4fe982ac475ae
languageName: node
linkType: hard

Expand All @@ -5125,7 +5125,7 @@ __metadata:
"@xmtp/content-type-group-updated": "npm:^2.0.0"
"@xmtp/content-type-primitives": "npm:^2.0.0"
"@xmtp/content-type-text": "npm:^2.0.0"
"@xmtp/node-bindings": "npm:^0.0.28"
"@xmtp/node-bindings": "npm:^0.0.29"
"@xmtp/proto": "npm:^3.72.3"
"@xmtp/xmtp-js": "workspace:^"
fast-glob: "npm:^3.3.2"
Expand Down

0 comments on commit cbfeb2a

Please sign in to comment.