mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-10 23:47:11 +00:00
core, ui: relay management - add, remove relays, synchronization to relay list (#6917)
This commit is contained in:
@@ -1891,6 +1891,22 @@ func apiGetGroupRelays(_ groupId: Int64) async -> [GroupRelay] {
|
||||
return []
|
||||
}
|
||||
|
||||
enum AddGroupRelaysResult {
|
||||
case added(GroupInfo, GroupLink, [GroupRelay])
|
||||
case addFailed([AddRelayResult])
|
||||
}
|
||||
|
||||
func apiAddGroupRelays(_ groupId: Int64, relayIds: [Int64]) async throws -> AddGroupRelaysResult? {
|
||||
let r: APIResult<ChatResponse2>? = await chatApiSendCmdWithRetry(.apiAddGroupRelays(groupId: groupId, relayIds: relayIds))
|
||||
switch r {
|
||||
case let .result(.groupRelaysAdded(_, groupInfo, groupLink, groupRelays)):
|
||||
return .added(groupInfo, groupLink, groupRelays)
|
||||
case let .result(.groupRelaysAddFailed(_, addRelayResults)):
|
||||
return .addFailed(addRelayResults)
|
||||
default: if let r { throw r.unexpected } else { return nil }
|
||||
}
|
||||
}
|
||||
|
||||
func apiAddMember(_ groupId: Int64, _ contactId: Int64, _ memberRole: GroupMemberRole) async throws -> GroupMember {
|
||||
let r: ChatResponse2 = try await chatSendCmd(.apiAddMember(groupId: groupId, contactId: contactId, memberRole: memberRole))
|
||||
if case let .sentGroupInvitation(_, _, _, member) = r { return member }
|
||||
|
||||
Reference in New Issue
Block a user