Skip to content

Commit

Permalink
update the content type
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed May 29, 2024
1 parent 98f6e3b commit a6ec504
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import org.xmtp.android.library.codecs.description
import org.xmtp.android.library.codecs.getReactionAction
import org.xmtp.android.library.codecs.getReactionSchema
import org.xmtp.android.library.codecs.id
import uniffi.xmtpv3.org.xmtp.android.library.codecs.ContentTypeGroupMembershipChange
import uniffi.xmtpv3.org.xmtp.android.library.codecs.GroupMembershipChangeCodec
import uniffi.xmtpv3.org.xmtp.android.library.codecs.GroupMembershipChanges
import java.net.URL

class ContentJson(
Expand All @@ -54,7 +51,7 @@ class ContentJson(
Client.register(RemoteAttachmentCodec())
Client.register(ReplyCodec())
Client.register(ReadReceiptCodec())
Client.register(GroupMembershipChangeCodec())
Client.register(GroupUpdatedCodec())
}

fun fromJsonObject(obj: JsonObject): ContentJson {
Expand Down Expand Up @@ -175,17 +172,17 @@ class ContentJson(
"readReceipt" to ""
)

ContentTypeGroupMembershipChange.id -> mapOf(
ContentTypeGroupUpdated.id -> mapOf(
"groupChange" to mapOf(
"membersAdded" to (content as GroupMembershipChanges).membersAddedList.map {
"membersAdded" to (content as GroupUpdated).addedInboxesList.map {
mapOf(
"address" to it.accountAddress,
"initiatedByAddress" to it.initiatedByAccountAddress
"inboxId" to it.inboxId,
"initiatedByInboxId" to it.initiatedByInboxId
)},
"membersRemoved" to content.membersRemovedList.map {
"membersRemoved" to content.removedInboxesList.map {
mapOf(
"address" to it.accountAddress,
"initiatedByAddress" to it.initiatedByAccountAddress
"inboxId" to it.inboxId,
"initiatedByInboxId" to it.initiatedByInboxId
)},
)
)
Expand Down
18 changes: 9 additions & 9 deletions ios/Wrappers/DecodedMessageWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct ContentJson {
ReplyCodec(),
RemoteAttachmentCodec(),
ReadReceiptCodec(),
GroupMembershipChangedCodec(),
GroupUpdatedCodec(),
]

static func initCodecs(client: Client) {
Expand Down Expand Up @@ -162,19 +162,19 @@ 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
case ContentTypeGroupUpdated.id where content is XMTP.GroupUpdated:
let groupChange = content as! XMTP.GroupUpdated
return ["groupChange": [
"membersAdded": groupChange.membersAdded.map { member in
"membersAdded": groupChange.addedInboxes.map { member in
[
"address": member.accountAddress,
"initiatedByAddress": member.initiatedByAccountAddress
"inboxId": member.inboxID,
"initiatedByInboxId": member.initiatedByInboxID
]
},
"membersRemoved": groupChange.membersRemoved.map { member in
"membersRemoved": groupChange.removedInboxes.map { member in
[
"address": member.accountAddress,
"initiatedByAddress": member.initiatedByAccountAddress
"inboxId": member.inboxID,
"initiatedByInboxId": member.initiatedByInboxID
]
},
]]
Expand Down

0 comments on commit a6ec504

Please sign in to comment.