Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Members Change Codec iOS #264

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions ios/Wrappers/DecodedMessageWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ struct ContentJson {
ReplyCodec(),
RemoteAttachmentCodec(),
ReadReceiptCodec(),
// TODO:
// CompositeCodec(),
GroupMembershipChangedCodec(),
]

static func initCodecs(client: Client) {
Expand Down Expand Up @@ -159,6 +158,22 @@ struct ContentJson {
]]
case ContentTypeReadReceipt.id where content is XMTP.ReadReceipt:
return ["readReceipt": ""]
case ContentTypeGroupMembershipChanged.id where content is XMTP.GroupMembershipChanges:
let groupChange = content as! XMTP.GroupMembershipChanges
return ["groupChange": [
"membersAdded": groupChange.membersAdded.map { member in
[
"address": member.accountAddress,
"initiatedByAddress": member.initiatedByAccountAddress
]
},
"membersRemoved": groupChange.membersRemoved.map { member in
[
"address": member.accountAddress,
"initiatedByAddress": member.initiatedByAccountAddress
]
},
]]
default:
if let encodedContent, let encodedContentJSON = try? encodedContent.jsonString() {
return ["encoded": encodedContentJSON]
Expand Down
4 changes: 2 additions & 2 deletions src/lib/NativeCodecs/GroupChangeCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class GroupChangeCodec
versionMajor: 1,
versionMinor: 0,
}

// Should never have to encode since only sent from Rust backend
encode(): NativeMessageContent {
return {}
}
Expand All @@ -25,6 +25,6 @@ export class GroupChangeCodec
}

fallback(): string | undefined {
return 'The members of this group have changed'
return undefined
}
}
Loading