mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-27 22:34:51 +00:00
core: fix short link type when adding for group link (#5942)
* core: fix short link type when adding for group link * shorten, rename * update setContactShortLink * update * fix * plans * simplexmq * ui: show error when setting short link --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
co-authored by
Evgeny Poberezkin
parent
6acd239339
commit
b2bc4d6a5c
+17
-13
@@ -1570,11 +1570,13 @@ object ChatController {
|
||||
return null
|
||||
}
|
||||
|
||||
suspend fun apiAddShortLinkMyAddress(rh: Long?): UserContactLinkRec? {
|
||||
val userId = kotlin.runCatching { currentUserId("apiAddShortLinkMyAddress") }.getOrElse { return null }
|
||||
val r = sendCmd(rh, CC.ApiAddShortLinkMyAddress(userId))
|
||||
suspend fun apiAddMyAddressShortLink(rh: Long?): UserContactLinkRec? {
|
||||
val userId = kotlin.runCatching { currentUserId("apiAddMyAddressShortLink") }.getOrElse { return null }
|
||||
val r = sendCmd(rh, CC.ApiAddMyAddressShortLink(userId))
|
||||
if (r is API.Result && r.res is CR.UserContactLink) return r.res.contactLink
|
||||
Log.e(TAG, "apiAddShortLinkMyAddress bad response: ${r.responseType} ${r.details}")
|
||||
if (!(networkErrorAlert(r))) {
|
||||
apiErrorAlert("apiAddMyAddressShortLink", generalGetString(MR.strings.error_creating_address), r)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -2024,10 +2026,12 @@ object ChatController {
|
||||
return null
|
||||
}
|
||||
|
||||
suspend fun apiAddShortLinkGroupLink(rh: Long?, groupId: Long): Pair<CreatedConnLink, GroupMemberRole>? {
|
||||
val r = sendCmd(rh, CC.APIAddShortLinkGroupLink(groupId))
|
||||
suspend fun apiAddGroupShortLink(rh: Long?, groupId: Long): Pair<CreatedConnLink, GroupMemberRole>? {
|
||||
val r = sendCmd(rh, CC.ApiAddGroupShortLink(groupId))
|
||||
if (r is API.Result && r.res is CR.GroupLink) return r.res.connLinkContact to r.res.memberRole
|
||||
Log.e(TAG, "apiAddShortLinkGroupLink bad response: ${r.responseType} ${r.details}")
|
||||
if (!(networkErrorAlert(r))) {
|
||||
apiErrorAlert("apiAddGroupShortLink", generalGetString(MR.strings.error_creating_link_for_group), r)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -3383,7 +3387,7 @@ sealed class CC {
|
||||
class APIGroupLinkMemberRole(val groupId: Long, val memberRole: GroupMemberRole): CC()
|
||||
class APIDeleteGroupLink(val groupId: Long): CC()
|
||||
class APIGetGroupLink(val groupId: Long): CC()
|
||||
class APIAddShortLinkGroupLink(val groupId: Long): CC()
|
||||
class ApiAddGroupShortLink(val groupId: Long): CC()
|
||||
class APICreateMemberContact(val groupId: Long, val groupMemberId: Long): CC()
|
||||
class APISendMemberContactInvitation(val contactId: Long, val mc: MsgContent): CC()
|
||||
class APITestProtoServer(val userId: Long, val server: String): CC()
|
||||
@@ -3438,7 +3442,7 @@ sealed class CC {
|
||||
class ApiCreateMyAddress(val userId: Long, val short: Boolean): CC()
|
||||
class ApiDeleteMyAddress(val userId: Long): CC()
|
||||
class ApiShowMyAddress(val userId: Long): CC()
|
||||
class ApiAddShortLinkMyAddress(val userId: Long): CC()
|
||||
class ApiAddMyAddressShortLink(val userId: Long): CC()
|
||||
class ApiSetProfileAddress(val userId: Long, val on: Boolean): CC()
|
||||
class ApiAddressAutoAccept(val userId: Long, val autoAccept: AutoAccept?): CC()
|
||||
class ApiGetCallInvitations: CC()
|
||||
@@ -3572,7 +3576,7 @@ sealed class CC {
|
||||
is APIGroupLinkMemberRole -> "/_set link role #$groupId ${memberRole.name.lowercase()}"
|
||||
is APIDeleteGroupLink -> "/_delete link #$groupId"
|
||||
is APIGetGroupLink -> "/_get link #$groupId"
|
||||
is APIAddShortLinkGroupLink -> "/_short link #$groupId"
|
||||
is ApiAddGroupShortLink -> "/_short link #$groupId"
|
||||
is APICreateMemberContact -> "/_create member contact #$groupId $groupMemberId"
|
||||
is APISendMemberContactInvitation -> "/_invite member contact @$contactId ${mc.cmdString}"
|
||||
is APITestProtoServer -> "/_server test $userId $server"
|
||||
@@ -3627,7 +3631,7 @@ sealed class CC {
|
||||
is ApiCreateMyAddress -> "/_address $userId short=${onOff(short)}"
|
||||
is ApiDeleteMyAddress -> "/_delete_address $userId"
|
||||
is ApiShowMyAddress -> "/_show_address $userId"
|
||||
is ApiAddShortLinkMyAddress -> "/_short_link_address $userId"
|
||||
is ApiAddMyAddressShortLink -> "/_short_link_address $userId"
|
||||
is ApiSetProfileAddress -> "/_profile_address $userId ${onOff(on)}"
|
||||
is ApiAddressAutoAccept -> "/_auto_accept $userId ${AutoAccept.cmdString(autoAccept)}"
|
||||
is ApiAcceptContact -> "/_accept incognito=${onOff(incognito)} $contactReqId"
|
||||
@@ -3739,7 +3743,7 @@ sealed class CC {
|
||||
is APIGroupLinkMemberRole -> "apiGroupLinkMemberRole"
|
||||
is APIDeleteGroupLink -> "apiDeleteGroupLink"
|
||||
is APIGetGroupLink -> "apiGetGroupLink"
|
||||
is APIAddShortLinkGroupLink -> "apiAddShortLinkGroupLink"
|
||||
is ApiAddGroupShortLink -> "apiAddGroupShortLink"
|
||||
is APICreateMemberContact -> "apiCreateMemberContact"
|
||||
is APISendMemberContactInvitation -> "apiSendMemberContactInvitation"
|
||||
is APITestProtoServer -> "testProtoServer"
|
||||
@@ -3794,7 +3798,7 @@ sealed class CC {
|
||||
is ApiCreateMyAddress -> "apiCreateMyAddress"
|
||||
is ApiDeleteMyAddress -> "apiDeleteMyAddress"
|
||||
is ApiShowMyAddress -> "apiShowMyAddress"
|
||||
is ApiAddShortLinkMyAddress -> "apiAddShortLinkMyAddress"
|
||||
is ApiAddMyAddressShortLink -> "apiAddMyAddressShortLink"
|
||||
is ApiSetProfileAddress -> "apiSetProfileAddress"
|
||||
is ApiAddressAutoAccept -> "apiAddressAutoAccept"
|
||||
is ApiAcceptContact -> "apiAcceptContact"
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ fun GroupLinkView(
|
||||
fun addShortLink() {
|
||||
creatingLink = true
|
||||
withBGApi {
|
||||
val link = chatModel.controller.apiAddShortLinkGroupLink(rhId, groupInfo.groupId)
|
||||
val link = chatModel.controller.apiAddGroupShortLink(rhId, groupInfo.groupId)
|
||||
if (link != null) {
|
||||
groupLink = link.first
|
||||
groupLinkMemberRole.value = link.second
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ fun UserAddressView(
|
||||
fun addShortLink() {
|
||||
withBGApi {
|
||||
progressIndicator = true
|
||||
val userAddress = chatModel.controller.apiAddShortLinkMyAddress(user.value?.remoteHostId)
|
||||
val userAddress = chatModel.controller.apiAddMyAddressShortLink(user.value?.remoteHostId)
|
||||
if (userAddress != null) {
|
||||
chatModel.userAddress.value = userAddress
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user