mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-06 14:25:04 +00:00
create group ttl
This commit is contained in:
parent
9ef6dd2b1b
commit
6c9850b277
@ -13,7 +13,7 @@ public enum CreateGroupError {
|
|||||||
case serverProvided(String)
|
case serverProvided(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_createGroup(account: Account, title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
func _internal_createGroup(account: Account, title: String, peerIds: [PeerId], ttlPeriod: Int32?) -> Signal<PeerId?, CreateGroupError> {
|
||||||
return account.postbox.transaction { transaction -> Signal<PeerId?, CreateGroupError> in
|
return account.postbox.transaction { transaction -> Signal<PeerId?, CreateGroupError> in
|
||||||
var inputUsers: [Api.InputUser] = []
|
var inputUsers: [Api.InputUser] = []
|
||||||
for peerId in peerIds {
|
for peerId in peerIds {
|
||||||
@ -23,7 +23,13 @@ func _internal_createGroup(account: Account, title: String, peerIds: [PeerId]) -
|
|||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return account.network.request(Api.functions.messages.createChat(flags: 0, users: inputUsers, title: title, ttlPeriod: nil))
|
|
||||||
|
var flags: Int32 = 0
|
||||||
|
if let _ = ttlPeriod {
|
||||||
|
flags |= 1 << 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return account.network.request(Api.functions.messages.createChat(flags: flags, users: inputUsers, title: title, ttlPeriod: ttlPeriod))
|
||||||
|> mapError { error -> CreateGroupError in
|
|> mapError { error -> CreateGroupError in
|
||||||
if error.errorDescription == "USERS_TOO_FEW" {
|
if error.errorDescription == "USERS_TOO_FEW" {
|
||||||
return .privacy
|
return .privacy
|
||||||
|
|||||||
@ -137,8 +137,8 @@ public extension TelegramEngine {
|
|||||||
return _internal_convertGroupToSupergroup(account: self.account, peerId: peerId)
|
return _internal_convertGroupToSupergroup(account: self.account, peerId: peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createGroup(title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
public func createGroup(title: String, peerIds: [PeerId], ttlPeriod: Int32?) -> Signal<PeerId?, CreateGroupError> {
|
||||||
return _internal_createGroup(account: self.account, title: title, peerIds: peerIds)
|
return _internal_createGroup(account: self.account, title: title, peerIds: peerIds, ttlPeriod: ttlPeriod)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createSecretChat(peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> {
|
public func createSecretChat(peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user