mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-13 01:40:12 +00:00
Merge commit '7ba618ae65937ad833d76dc816fb8e7a2d3ee45b'
This commit is contained in:
commit
da68a6d0db
@ -2044,6 +2044,16 @@ func replayFinalState(accountPeerId: PeerId, mediaBox: MediaBox, transaction: Tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if case let .Id(id) = message.id {
|
||||||
|
for media in message.media {
|
||||||
|
if let action = media as? TelegramMediaAction, case .groupCreated = action.action {
|
||||||
|
if let hole = transaction.getHole(messageId: MessageId(peerId: chatPeerId, namespace: Namespaces.Message.Cloud, id: id.id - 1)) {
|
||||||
|
transaction.fillHole(hole, fillType: HoleFill(complete: true, direction: .UpperToLower(updatedMinIndex: nil, clippingMaxIndex: nil)), tagMask: nil, messages: [])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !message.flags.contains(.Incoming), message.forwardInfo == nil {
|
if !message.flags.contains(.Incoming), message.forwardInfo == nil {
|
||||||
inner: for media in message.media {
|
inner: for media in message.media {
|
||||||
if let file = media as? TelegramMediaFile {
|
if let file = media as? TelegramMediaFile {
|
||||||
|
|||||||
@ -36,6 +36,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
public let reportStatus: PeerReportStatus
|
public let reportStatus: PeerReportStatus
|
||||||
public let pinnedMessageId: MessageId?
|
public let pinnedMessageId: MessageId?
|
||||||
public let defaultBannedRights: TelegramChatBannedRights?
|
public let defaultBannedRights: TelegramChatBannedRights?
|
||||||
|
public let about: String?
|
||||||
|
|
||||||
public let peerIds: Set<PeerId>
|
public let peerIds: Set<PeerId>
|
||||||
public let messageIds: Set<MessageId>
|
public let messageIds: Set<MessageId>
|
||||||
@ -50,9 +51,10 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
self.messageIds = Set()
|
self.messageIds = Set()
|
||||||
self.peerIds = Set()
|
self.peerIds = Set()
|
||||||
self.defaultBannedRights = nil
|
self.defaultBannedRights = nil
|
||||||
|
self.about = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, defaultBannedRights: TelegramChatBannedRights?) {
|
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, defaultBannedRights: TelegramChatBannedRights?, about: String?) {
|
||||||
self.participants = participants
|
self.participants = participants
|
||||||
self.exportedInvitation = exportedInvitation
|
self.exportedInvitation = exportedInvitation
|
||||||
self.botInfos = botInfos
|
self.botInfos = botInfos
|
||||||
@ -76,6 +78,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
peerIds.insert(botInfo.peerId)
|
peerIds.insert(botInfo.peerId)
|
||||||
}
|
}
|
||||||
self.peerIds = peerIds
|
self.peerIds = peerIds
|
||||||
|
self.about = about
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
@ -90,6 +93,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
self.pinnedMessageId = nil
|
self.pinnedMessageId = nil
|
||||||
}
|
}
|
||||||
self.defaultBannedRights = decoder.decodeObjectForKey("defbr", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
self.defaultBannedRights = decoder.decodeObjectForKey("defbr", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
||||||
|
self.about = decoder.decodeOptionalStringForKey("ab")
|
||||||
|
|
||||||
var messageIds = Set<MessageId>()
|
var messageIds = Set<MessageId>()
|
||||||
if let pinnedMessageId = self.pinnedMessageId {
|
if let pinnedMessageId = self.pinnedMessageId {
|
||||||
@ -137,6 +141,11 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "defbr")
|
encoder.encodeNil(forKey: "defbr")
|
||||||
}
|
}
|
||||||
|
if let about = self.about {
|
||||||
|
encoder.encodeString(about, forKey: "ab")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "ab")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to: CachedPeerData) -> Bool {
|
public func isEqual(to: CachedPeerData) -> Bool {
|
||||||
@ -144,30 +153,34 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.reportStatus == other.reportStatus && self.pinnedMessageId == other.pinnedMessageId && self.defaultBannedRights == other.defaultBannedRights
|
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.reportStatus == other.reportStatus && self.pinnedMessageId == other.pinnedMessageId && self.defaultBannedRights == other.defaultBannedRights && self.about == other.about
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedParticipants(_ participants: CachedGroupParticipants?) -> CachedGroupData {
|
func withUpdatedParticipants(_ participants: CachedGroupParticipants?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights)
|
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedGroupData {
|
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights)
|
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedGroupData {
|
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedReportStatus(_ reportStatus: PeerReportStatus) -> CachedGroupData {
|
func withUpdatedReportStatus(_ reportStatus: PeerReportStatus) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedGroupData {
|
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, defaultBannedRights: self.defaultBannedRights)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedDefaultBannedRights(_ defaultBannedRights: TelegramChatBannedRights?) -> CachedGroupData {
|
func withUpdatedDefaultBannedRights(_ defaultBannedRights: TelegramChatBannedRights?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: defaultBannedRights)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: defaultBannedRights, about: self.about)
|
||||||
|
}
|
||||||
|
|
||||||
|
func withUpdatedAbout(_ about: String?) -> CachedGroupData {
|
||||||
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: about)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,28 +20,29 @@ public func createGroup(account: Account, title: String, peerIds: [PeerId]) -> S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return account.network.request(Api.functions.messages.createChat(users: inputUsers, title: title))
|
return account.network.request(Api.functions.messages.createChat(users: inputUsers, title: title))
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { _ in
|
|> `catch` { _ in
|
||||||
return Signal<Api.Updates?, NoError>.single(nil)
|
return Signal<Api.Updates?, NoError>.single(nil)
|
||||||
}
|
}
|
||||||
|> mapToSignal { updates -> Signal<PeerId?, NoError> in
|
|> mapToSignal { updates -> Signal<PeerId?, NoError> in
|
||||||
if let updates = updates {
|
if let updates = updates {
|
||||||
account.stateManager.addUpdates(updates)
|
account.stateManager.addUpdates(updates)
|
||||||
if let message = updates.messages.first, let peerId = apiMessagePeerId(message) {
|
if let message = updates.messages.first, let peerId = apiMessagePeerId(message) {
|
||||||
return account.postbox.multiplePeersView([peerId])
|
return account.postbox.multiplePeersView([peerId])
|
||||||
|> filter { view in
|
|> filter { view in
|
||||||
return view.peers[peerId] != nil
|
return view.peers[peerId] != nil
|
||||||
}
|
|
||||||
|> take(1)
|
|
||||||
|> map { _ in
|
|
||||||
return peerId
|
|
||||||
}
|
|
||||||
|> timeout(5.0, queue: Queue.concurrentDefaultQueue(), alternate: .single(nil))
|
|
||||||
}
|
}
|
||||||
return .single(nil)
|
|> take(1)
|
||||||
} else {
|
|> map { _ in
|
||||||
return .single(nil)
|
return peerId
|
||||||
|
}
|
||||||
|
|> timeout(5.0, queue: Queue.concurrentDefaultQueue(), alternate: .single(nil))
|
||||||
}
|
}
|
||||||
|
return .single(nil)
|
||||||
|
} else {
|
||||||
|
return .single(nil)
|
||||||
}
|
}
|
||||||
} |> switchToLatest
|
}
|
||||||
|
}
|
||||||
|
|> switchToLatest
|
||||||
}
|
}
|
||||||
|
|||||||
@ -220,6 +220,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
|||||||
.withUpdatedBotInfos(botInfos)
|
.withUpdatedBotInfos(botInfos)
|
||||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||||
.withUpdatedDefaultBannedRights(defaultBannedRights)
|
.withUpdatedDefaultBannedRights(defaultBannedRights)
|
||||||
|
.withUpdatedAbout(chatFull.about)
|
||||||
})
|
})
|
||||||
case .channelFull:
|
case .channelFull:
|
||||||
break
|
break
|
||||||
|
|||||||
@ -75,6 +75,8 @@ public func updatePeerDescription(account: Account, peerId: PeerId, description:
|
|||||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||||
if let current = current as? CachedChannelData {
|
if let current = current as? CachedChannelData {
|
||||||
return current.withUpdatedAbout(description)
|
return current.withUpdatedAbout(description)
|
||||||
|
} else if let current = current as? CachedGroupData {
|
||||||
|
return current.withUpdatedAbout(description)
|
||||||
} else {
|
} else {
|
||||||
return current
|
return current
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user