diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupChatTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupChatTest.kt deleted file mode 100644 index b31c5dbef..000000000 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupChatTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -package org.xmtp.android.library - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith -import org.xmtp.android.library.codecs.ContentTypeGroupChatMemberAdded -import org.xmtp.android.library.codecs.ContentTypeGroupTitleChangedAdded -import org.xmtp.android.library.codecs.GroupChatMemberAdded -import org.xmtp.android.library.codecs.GroupChatTitleChanged -import org.xmtp.android.library.messages.walletAddress - -@RunWith(AndroidJUnit4::class) -class GroupChatTest { - @Test - fun testCanAddMemberToGroupChatCodec() { - val fixtures = fixtures() - val aliceClient = fixtures.aliceClient - aliceClient.enableGroupChat() - val aliceConversation = - aliceClient.conversations.newConversation(fixtures.bob.walletAddress) - - val personAdded = GroupChatMemberAdded( - member = fixtures.steve.walletAddress, - ) - - aliceConversation.send( - content = personAdded, - options = SendOptions(contentType = ContentTypeGroupChatMemberAdded), - ) - val messages = aliceConversation.messages() - assertEquals(messages.size, 1) - val content: GroupChatMemberAdded? = messages[0].content() - assertEquals(fixtures.steve.walletAddress, content?.member) - } - - @Test - fun testCanChangeGroupChatNameCodec() { - val fixtures = fixtures() - val aliceClient = fixtures.aliceClient - aliceClient.enableGroupChat() - val aliceConversation = - aliceClient.conversations.newConversation(fixtures.bob.walletAddress) - - val titleChange = GroupChatTitleChanged( - newTitle = "New Title", - ) - - aliceConversation.send( - content = titleChange, - options = SendOptions(contentType = ContentTypeGroupTitleChangedAdded), - ) - val messages = aliceConversation.messages() - assertEquals(messages.size, 1) - val content: GroupChatTitleChanged? = messages[0].content() - assertEquals("New Title", content?.newTitle) - } -} diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index 5236002ea..637767855 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -34,7 +34,6 @@ import org.xmtp.android.library.messages.walletAddress import org.xmtp.proto.message.api.v1.MessageApiOuterClass import org.xmtp.proto.message.api.v1.MessageApiOuterClass.BatchQueryResponse import org.xmtp.proto.message.api.v1.MessageApiOuterClass.QueryRequest -import uniffi.xmtp_dh.org.xmtp.android.library.GroupChat import java.nio.charset.StandardCharsets import java.text.SimpleDateFormat import java.time.Instant @@ -59,8 +58,6 @@ class Client() { lateinit var apiClient: ApiClient lateinit var contacts: Contacts lateinit var conversations: Conversations - var isGroupChatEnabled: Boolean = false - private set companion object { private const val TAG = "Client" @@ -355,9 +352,4 @@ class Client() { val keys: PrivateKeyBundleV2 get() = privateKeyBundleV1.toV2() - - fun enableGroupChat() { - this.isGroupChatEnabled = true - GroupChat.registerCodecs() - } } diff --git a/library/src/main/java/org/xmtp/android/library/Conversation.kt b/library/src/main/java/org/xmtp/android/library/Conversation.kt index 05fbbb8ef..48172140f 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversation.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversation.kt @@ -19,14 +19,6 @@ sealed class Conversation { V2 } - val isGroup: Boolean - get() { - return when (this) { - is V1 -> false - is V2 -> conversationV2.isGroup - } - } - val version: Version get() { return when (this) { diff --git a/library/src/main/java/org/xmtp/android/library/ConversationV2.kt b/library/src/main/java/org/xmtp/android/library/ConversationV2.kt index 71165aa50..9d4e99c18 100644 --- a/library/src/main/java/org/xmtp/android/library/ConversationV2.kt +++ b/library/src/main/java/org/xmtp/android/library/ConversationV2.kt @@ -28,7 +28,6 @@ data class ConversationV2( val context: Invitation.InvitationV1.Context, val peerAddress: String, val client: Client, - val isGroup: Boolean = false, private val header: SealedInvitationHeaderV1, ) { @@ -37,7 +36,6 @@ data class ConversationV2( client: Client, invitation: Invitation.InvitationV1, header: SealedInvitationHeaderV1, - isGroup: Boolean = false, ): ConversationV2 { val myKeys = client.keys.getPublicKeyBundle() val peer = @@ -51,7 +49,6 @@ data class ConversationV2( peerAddress = peerAddress, client = client, header = header, - isGroup = isGroup ) } } diff --git a/library/src/main/java/org/xmtp/android/library/Conversations.kt b/library/src/main/java/org/xmtp/android/library/Conversations.kt index fb2044ec3..39303c853 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversations.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversations.kt @@ -169,13 +169,6 @@ data class Conversations( Log.d(TAG, e.message.toString()) } } - for (sealedInvitation in listGroupInvitations()) { - try { - newConversations.add(Conversation.V2(conversation(sealedInvitation, true))) - } catch (e: Exception) { - Log.d(TAG, e.message.toString()) - } - } conversationsByTopic += newConversations.filter { it.peerAddress != client.address } .map { Pair(it.topic, it) } @@ -203,7 +196,6 @@ data class Conversations( context = data.invitation.context, peerAddress = data.peerAddress, client = client, - isGroup = false, header = Invitation.SealedInvitationHeaderV1.getDefaultInstance() ) ) @@ -259,28 +251,12 @@ data class Conversations( } } - private fun listGroupInvitations(): List { - if (!client.isGroupChatEnabled) { - return listOf() - } - val envelopes = runBlocking { - client.apiClient.envelopes( - topic = Topic.groupInvite(client.address).description, - pagination = null - ) - } - return envelopes.map { envelope -> - SealedInvitation.parseFrom(envelope.message) - } - } - - fun conversation(sealedInvitation: SealedInvitation, isGroup: Boolean = false): ConversationV2 { + fun conversation(sealedInvitation: SealedInvitation): ConversationV2 { val unsealed = sealedInvitation.v1.getInvitation(viewer = client.keys) return ConversationV2.create( client = client, invitation = unsealed, header = sealedInvitation.v1.header, - isGroup = isGroup ) } diff --git a/library/src/main/java/org/xmtp/android/library/GroupChat.kt b/library/src/main/java/org/xmtp/android/library/GroupChat.kt deleted file mode 100644 index 822c2f1ca..000000000 --- a/library/src/main/java/org/xmtp/android/library/GroupChat.kt +++ /dev/null @@ -1,14 +0,0 @@ -package uniffi.xmtp_dh.org.xmtp.android.library - -import org.xmtp.android.library.Client -import org.xmtp.android.library.codecs.GroupChatMemberAddedCodec -import org.xmtp.android.library.codecs.GroupChatTitleChangedCodec - -class GroupChat { - companion object { - fun registerCodecs() { - Client.register(codec = GroupChatMemberAddedCodec()) - Client.register(codec = GroupChatTitleChangedCodec()) - } - } -} diff --git a/library/src/main/java/org/xmtp/android/library/codecs/GroupChatMemberAddedCodec.kt b/library/src/main/java/org/xmtp/android/library/codecs/GroupChatMemberAddedCodec.kt deleted file mode 100644 index 8eaa5bc12..000000000 --- a/library/src/main/java/org/xmtp/android/library/codecs/GroupChatMemberAddedCodec.kt +++ /dev/null @@ -1,31 +0,0 @@ -package org.xmtp.android.library.codecs - -import com.google.gson.GsonBuilder -import com.google.protobuf.kotlin.toByteStringUtf8 - -val ContentTypeGroupChatMemberAdded = ContentTypeIdBuilder.builderFromAuthorityId( - "xmtp.org", - "groupChatMemberAdded", - versionMajor = 1, - versionMinor = 0 -) - -// The address of the member being added -data class GroupChatMemberAdded(var member: String) - -data class GroupChatMemberAddedCodec(override var contentType: ContentTypeId = ContentTypeGroupChatMemberAdded) : - ContentCodec { - - override fun encode(content: GroupChatMemberAdded): EncodedContent { - val gson = GsonBuilder().create() - return EncodedContent.newBuilder().also { - it.type = ContentTypeGroupChatMemberAdded - it.content = gson.toJson(content).toByteStringUtf8() - }.build() - } - - override fun decode(content: EncodedContent): GroupChatMemberAdded { - val gson = GsonBuilder().create() - return gson.fromJson(content.content.toStringUtf8(), GroupChatMemberAdded::class.java) - } -} diff --git a/library/src/main/java/org/xmtp/android/library/codecs/GroupChatTitleChangedCodec.kt b/library/src/main/java/org/xmtp/android/library/codecs/GroupChatTitleChangedCodec.kt deleted file mode 100644 index 882b746b6..000000000 --- a/library/src/main/java/org/xmtp/android/library/codecs/GroupChatTitleChangedCodec.kt +++ /dev/null @@ -1,31 +0,0 @@ -package org.xmtp.android.library.codecs - -import com.google.gson.GsonBuilder -import com.google.protobuf.kotlin.toByteStringUtf8 - -val ContentTypeGroupTitleChangedAdded = ContentTypeIdBuilder.builderFromAuthorityId( - "xmtp.org", - "groupChatTitleChanged", - versionMajor = 1, - versionMinor = 0 -) - -// The new title -data class GroupChatTitleChanged(var newTitle: String) - -data class GroupChatTitleChangedCodec(override var contentType: ContentTypeId = ContentTypeGroupTitleChangedAdded) : - ContentCodec { - - override fun encode(content: GroupChatTitleChanged): EncodedContent { - val gson = GsonBuilder().create() - return EncodedContent.newBuilder().also { - it.type = ContentTypeGroupTitleChangedAdded - it.content = gson.toJson(content).toByteStringUtf8() - }.build() - } - - override fun decode(content: EncodedContent): GroupChatTitleChanged { - val gson = GsonBuilder().create() - return gson.fromJson(content.content.toStringUtf8(), GroupChatTitleChanged::class.java) - } -} diff --git a/library/src/main/java/org/xmtp/android/library/codecs/README.md b/library/src/main/java/org/xmtp/android/library/codecs/README.md index 361cd1f2d..418e2f24f 100644 --- a/library/src/main/java/org/xmtp/android/library/codecs/README.md +++ b/library/src/main/java/org/xmtp/android/library/codecs/README.md @@ -9,6 +9,7 @@ When you build an app with XMTP, all messages are encoded with a [content type]( - `RemoteAttachmentCodec`: Enables sending remote attachments. - `ReactionCodec`: Enables sending of reactions. - `ReplyCodec`: Enables sending of replies. +- `ReadReceiptCodec`: Enables read receipts. ## Support remote media attachments