File tree 2 files changed +23
-2
lines changed
library/src/main/java/org/xmtp/android/library
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,11 @@ sealed class Conversation {
55
55
return when (this ) {
56
56
is V1 -> conversationV1.peerAddress
57
57
is V2 -> conversationV2.peerAddress
58
- is Group -> group.memberAddresses().joinToString(" ," )
58
+ is Group -> {
59
+ val addresses = group.memberAddresses().toMutableList()
60
+ addresses.remove(clientAddress)
61
+ addresses.joinToString(" ," )
62
+ }
59
63
}
60
64
}
61
65
@@ -64,7 +68,11 @@ sealed class Conversation {
64
68
return when (this ) {
65
69
is V1 -> listOf (conversationV1.peerAddress)
66
70
is V2 -> listOf (conversationV2.peerAddress)
67
- is Group -> group.memberAddresses()
71
+ is Group -> {
72
+ val addresses = group.memberAddresses().toMutableList()
73
+ addresses.remove(clientAddress)
74
+ addresses
75
+ }
68
76
}
69
77
}
70
78
Original file line number Diff line number Diff line change @@ -90,6 +90,19 @@ data class Conversations(
90
90
}
91
91
92
92
fun newGroup (accountAddresses : List <String >): Group {
93
+ if (accountAddresses.isEmpty()) {
94
+ throw XMTPException (" Cannot start an empty group chat." )
95
+ }
96
+ if (accountAddresses.size == 1 && accountAddresses.first()
97
+ .lowercase() == client.address.lowercase()
98
+ ) {
99
+ throw XMTPException (" Recipient is sender" )
100
+ }
101
+ val contacts = accountAddresses.map { client.contacts.find(it) }
102
+ if (contacts.size != accountAddresses.size) {
103
+ throw XMTPException (" Recipient not on network" )
104
+ }
105
+
93
106
val group = runBlocking {
94
107
libXMTPConversations?.createGroup(accountAddresses)
95
108
? : throw XMTPException (" Client does not support Groups" )
You can’t perform that action at this time.
0 commit comments