Skip to content

Commit

Permalink
Merge pull request #264 from xmtp/np/members-change-codec
Browse files Browse the repository at this point in the history
Members Change Codec iOS
  • Loading branch information
nplasterer authored Feb 16, 2024
2 parents 5a2ef36 + 259440a commit 64f11d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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
}
}

0 comments on commit 64f11d5

Please sign in to comment.