Support monoforum reactions

This commit is contained in:
Isaac 2025-05-24 22:42:26 +08:00
parent 0542113ace
commit 5cdce4b21a
13 changed files with 143 additions and 75 deletions

View File

@ -872,7 +872,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1054465340] = { return Api.RichText.parse_textUnderline($0) } dict[-1054465340] = { return Api.RichText.parse_textUnderline($0) }
dict[1009288385] = { return Api.RichText.parse_textUrl($0) } dict[1009288385] = { return Api.RichText.parse_textUrl($0) }
dict[289586518] = { return Api.SavedContact.parse_savedPhoneContact($0) } dict[289586518] = { return Api.SavedContact.parse_savedPhoneContact($0) }
dict[2099641667] = { return Api.SavedDialog.parse_monoForumDialog($0) } dict[1681948327] = { return Api.SavedDialog.parse_monoForumDialog($0) }
dict[-1115174036] = { return Api.SavedDialog.parse_savedDialog($0) } dict[-1115174036] = { return Api.SavedDialog.parse_savedDialog($0) }
dict[-881854424] = { return Api.SavedReactionTag.parse_savedReactionTag($0) } dict[-881854424] = { return Api.SavedReactionTag.parse_savedReactionTag($0) }
dict[-539360103] = { return Api.SavedStarGift.parse_savedStarGift($0) } dict[-539360103] = { return Api.SavedStarGift.parse_savedStarGift($0) }
@ -1040,7 +1040,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1738720581] = { return Api.Update.parse_updateChannelParticipant($0) } dict[-1738720581] = { return Api.Update.parse_updateChannelParticipant($0) }
dict[422509539] = { return Api.Update.parse_updateChannelPinnedTopic($0) } dict[422509539] = { return Api.Update.parse_updateChannelPinnedTopic($0) }
dict[-31881726] = { return Api.Update.parse_updateChannelPinnedTopics($0) } dict[-31881726] = { return Api.Update.parse_updateChannelPinnedTopics($0) }
dict[-366410403] = { return Api.Update.parse_updateChannelReadMessagesContents($0) } dict[636691703] = { return Api.Update.parse_updateChannelReadMessagesContents($0) }
dict[277713951] = { return Api.Update.parse_updateChannelTooLong($0) } dict[277713951] = { return Api.Update.parse_updateChannelTooLong($0) }
dict[-1937192669] = { return Api.Update.parse_updateChannelUserTyping($0) } dict[-1937192669] = { return Api.Update.parse_updateChannelUserTyping($0) }
dict[129403168] = { return Api.Update.parse_updateChannelViewForumAsMessages($0) } dict[129403168] = { return Api.Update.parse_updateChannelViewForumAsMessages($0) }
@ -1087,7 +1087,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1318109142] = { return Api.Update.parse_updateMessageID($0) } dict[1318109142] = { return Api.Update.parse_updateMessageID($0) }
dict[-1398708869] = { return Api.Update.parse_updateMessagePoll($0) } dict[-1398708869] = { return Api.Update.parse_updateMessagePoll($0) }
dict[619974263] = { return Api.Update.parse_updateMessagePollVote($0) } dict[619974263] = { return Api.Update.parse_updateMessagePollVote($0) }
dict[1578843320] = { return Api.Update.parse_updateMessageReactions($0) } dict[506035194] = { return Api.Update.parse_updateMessageReactions($0) }
dict[-2030252155] = { return Api.Update.parse_updateMoveStickerSetToTop($0) } dict[-2030252155] = { return Api.Update.parse_updateMoveStickerSetToTop($0) }
dict[-1991136273] = { return Api.Update.parse_updateNewAuthorization($0) } dict[-1991136273] = { return Api.Update.parse_updateNewAuthorization($0) }
dict[1656358105] = { return Api.Update.parse_updateNewChannelMessage($0) } dict[1656358105] = { return Api.Update.parse_updateNewChannelMessage($0) }

View File

@ -48,14 +48,14 @@ public extension Api {
} }
public extension Api { public extension Api {
indirect enum SavedDialog: TypeConstructorDescription { indirect enum SavedDialog: TypeConstructorDescription {
case monoForumDialog(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, draft: Api.DraftMessage?) case monoForumDialog(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadReactionsCount: Int32, draft: Api.DraftMessage?)
case savedDialog(flags: Int32, peer: Api.Peer, topMessage: Int32) case savedDialog(flags: Int32, peer: Api.Peer, topMessage: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .monoForumDialog(let flags, let peer, let topMessage, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let draft): case .monoForumDialog(let flags, let peer, let topMessage, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let unreadReactionsCount, let draft):
if boxed { if boxed {
buffer.appendInt32(2099641667) buffer.appendInt32(1681948327)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
@ -63,6 +63,7 @@ public extension Api {
serializeInt32(readInboxMaxId, buffer: buffer, boxed: false) serializeInt32(readInboxMaxId, buffer: buffer, boxed: false)
serializeInt32(readOutboxMaxId, buffer: buffer, boxed: false) serializeInt32(readOutboxMaxId, buffer: buffer, boxed: false)
serializeInt32(unreadCount, buffer: buffer, boxed: false) serializeInt32(unreadCount, buffer: buffer, boxed: false)
serializeInt32(unreadReactionsCount, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {draft!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {draft!.serialize(buffer, true)}
break break
case .savedDialog(let flags, let peer, let topMessage): case .savedDialog(let flags, let peer, let topMessage):
@ -78,8 +79,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .monoForumDialog(let flags, let peer, let topMessage, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let draft): case .monoForumDialog(let flags, let peer, let topMessage, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let unreadReactionsCount, let draft):
return ("monoForumDialog", [("flags", flags as Any), ("peer", peer as Any), ("topMessage", topMessage as Any), ("readInboxMaxId", readInboxMaxId as Any), ("readOutboxMaxId", readOutboxMaxId as Any), ("unreadCount", unreadCount as Any), ("draft", draft as Any)]) return ("monoForumDialog", [("flags", flags as Any), ("peer", peer as Any), ("topMessage", topMessage as Any), ("readInboxMaxId", readInboxMaxId as Any), ("readOutboxMaxId", readOutboxMaxId as Any), ("unreadCount", unreadCount as Any), ("unreadReactionsCount", unreadReactionsCount as Any), ("draft", draft as Any)])
case .savedDialog(let flags, let peer, let topMessage): case .savedDialog(let flags, let peer, let topMessage):
return ("savedDialog", [("flags", flags as Any), ("peer", peer as Any), ("topMessage", topMessage as Any)]) return ("savedDialog", [("flags", flags as Any), ("peer", peer as Any), ("topMessage", topMessage as Any)])
} }
@ -100,9 +101,11 @@ public extension Api {
_5 = reader.readInt32() _5 = reader.readInt32()
var _6: Int32? var _6: Int32?
_6 = reader.readInt32() _6 = reader.readInt32()
var _7: Api.DraftMessage? var _7: Int32?
_7 = reader.readInt32()
var _8: Api.DraftMessage?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.DraftMessage _8 = Api.parse(reader, signature: signature) as? Api.DraftMessage
} } } }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
@ -110,9 +113,10 @@ public extension Api {
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { let _c8 = (Int(_1!) & Int(1 << 1) == 0) || _8 != nil
return Api.SavedDialog.monoForumDialog(flags: _1!, peer: _2!, topMessage: _3!, readInboxMaxId: _4!, readOutboxMaxId: _5!, unreadCount: _6!, draft: _7) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.SavedDialog.monoForumDialog(flags: _1!, peer: _2!, topMessage: _3!, readInboxMaxId: _4!, readOutboxMaxId: _5!, unreadCount: _6!, unreadReactionsCount: _7!, draft: _8)
} }
else { else {
return nil return nil

View File

@ -1012,7 +1012,7 @@ public extension Api {
case updateChannelParticipant(flags: Int32, channelId: Int64, date: Int32, actorId: Int64, userId: Int64, prevParticipant: Api.ChannelParticipant?, newParticipant: Api.ChannelParticipant?, invite: Api.ExportedChatInvite?, qts: Int32) case updateChannelParticipant(flags: Int32, channelId: Int64, date: Int32, actorId: Int64, userId: Int64, prevParticipant: Api.ChannelParticipant?, newParticipant: Api.ChannelParticipant?, invite: Api.ExportedChatInvite?, qts: Int32)
case updateChannelPinnedTopic(flags: Int32, channelId: Int64, topicId: Int32) case updateChannelPinnedTopic(flags: Int32, channelId: Int64, topicId: Int32)
case updateChannelPinnedTopics(flags: Int32, channelId: Int64, order: [Int32]?) case updateChannelPinnedTopics(flags: Int32, channelId: Int64, order: [Int32]?)
case updateChannelReadMessagesContents(flags: Int32, channelId: Int64, topMsgId: Int32?, messages: [Int32]) case updateChannelReadMessagesContents(flags: Int32, channelId: Int64, topMsgId: Int32?, savedPeerId: Api.Peer?, messages: [Int32])
case updateChannelTooLong(flags: Int32, channelId: Int64, pts: Int32?) case updateChannelTooLong(flags: Int32, channelId: Int64, pts: Int32?)
case updateChannelUserTyping(flags: Int32, channelId: Int64, topMsgId: Int32?, fromId: Api.Peer, action: Api.SendMessageAction) case updateChannelUserTyping(flags: Int32, channelId: Int64, topMsgId: Int32?, fromId: Api.Peer, action: Api.SendMessageAction)
case updateChannelViewForumAsMessages(channelId: Int64, enabled: Api.Bool) case updateChannelViewForumAsMessages(channelId: Int64, enabled: Api.Bool)
@ -1059,7 +1059,7 @@ public extension Api {
case updateMessageID(id: Int32, randomId: Int64) case updateMessageID(id: Int32, randomId: Int64)
case updateMessagePoll(flags: Int32, pollId: Int64, poll: Api.Poll?, results: Api.PollResults) case updateMessagePoll(flags: Int32, pollId: Int64, poll: Api.Poll?, results: Api.PollResults)
case updateMessagePollVote(pollId: Int64, peer: Api.Peer, options: [Buffer], qts: Int32) case updateMessagePollVote(pollId: Int64, peer: Api.Peer, options: [Buffer], qts: Int32)
case updateMessageReactions(flags: Int32, peer: Api.Peer, msgId: Int32, topMsgId: Int32?, reactions: Api.MessageReactions) case updateMessageReactions(flags: Int32, peer: Api.Peer, msgId: Int32, topMsgId: Int32?, savedPeerId: Api.Peer?, reactions: Api.MessageReactions)
case updateMoveStickerSetToTop(flags: Int32, stickerset: Int64) case updateMoveStickerSetToTop(flags: Int32, stickerset: Int64)
case updateNewAuthorization(flags: Int32, hash: Int64, date: Int32?, device: String?, location: String?) case updateNewAuthorization(flags: Int32, hash: Int64, date: Int32?, device: String?, location: String?)
case updateNewChannelMessage(message: Api.Message, pts: Int32, ptsCount: Int32) case updateNewChannelMessage(message: Api.Message, pts: Int32, ptsCount: Int32)
@ -1426,13 +1426,14 @@ public extension Api {
serializeInt32(item, buffer: buffer, boxed: false) serializeInt32(item, buffer: buffer, boxed: false)
}} }}
break break
case .updateChannelReadMessagesContents(let flags, let channelId, let topMsgId, let messages): case .updateChannelReadMessagesContents(let flags, let channelId, let topMsgId, let savedPeerId, let messages):
if boxed { if boxed {
buffer.appendInt32(-366410403) buffer.appendInt32(636691703)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt64(channelId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {savedPeerId!.serialize(buffer, true)}
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
buffer.appendInt32(Int32(messages.count)) buffer.appendInt32(Int32(messages.count))
for item in messages { for item in messages {
@ -1846,14 +1847,15 @@ public extension Api {
} }
serializeInt32(qts, buffer: buffer, boxed: false) serializeInt32(qts, buffer: buffer, boxed: false)
break break
case .updateMessageReactions(let flags, let peer, let msgId, let topMsgId, let reactions): case .updateMessageReactions(let flags, let peer, let msgId, let topMsgId, let savedPeerId, let reactions):
if boxed { if boxed {
buffer.appendInt32(1578843320) buffer.appendInt32(506035194)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
serializeInt32(msgId, buffer: buffer, boxed: false) serializeInt32(msgId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {savedPeerId!.serialize(buffer, true)}
reactions.serialize(buffer, true) reactions.serialize(buffer, true)
break break
case .updateMoveStickerSetToTop(let flags, let stickerset): case .updateMoveStickerSetToTop(let flags, let stickerset):
@ -2461,8 +2463,8 @@ public extension Api {
return ("updateChannelPinnedTopic", [("flags", flags as Any), ("channelId", channelId as Any), ("topicId", topicId as Any)]) return ("updateChannelPinnedTopic", [("flags", flags as Any), ("channelId", channelId as Any), ("topicId", topicId as Any)])
case .updateChannelPinnedTopics(let flags, let channelId, let order): case .updateChannelPinnedTopics(let flags, let channelId, let order):
return ("updateChannelPinnedTopics", [("flags", flags as Any), ("channelId", channelId as Any), ("order", order as Any)]) return ("updateChannelPinnedTopics", [("flags", flags as Any), ("channelId", channelId as Any), ("order", order as Any)])
case .updateChannelReadMessagesContents(let flags, let channelId, let topMsgId, let messages): case .updateChannelReadMessagesContents(let flags, let channelId, let topMsgId, let savedPeerId, let messages):
return ("updateChannelReadMessagesContents", [("flags", flags as Any), ("channelId", channelId as Any), ("topMsgId", topMsgId as Any), ("messages", messages as Any)]) return ("updateChannelReadMessagesContents", [("flags", flags as Any), ("channelId", channelId as Any), ("topMsgId", topMsgId as Any), ("savedPeerId", savedPeerId as Any), ("messages", messages as Any)])
case .updateChannelTooLong(let flags, let channelId, let pts): case .updateChannelTooLong(let flags, let channelId, let pts):
return ("updateChannelTooLong", [("flags", flags as Any), ("channelId", channelId as Any), ("pts", pts as Any)]) return ("updateChannelTooLong", [("flags", flags as Any), ("channelId", channelId as Any), ("pts", pts as Any)])
case .updateChannelUserTyping(let flags, let channelId, let topMsgId, let fromId, let action): case .updateChannelUserTyping(let flags, let channelId, let topMsgId, let fromId, let action):
@ -2555,8 +2557,8 @@ public extension Api {
return ("updateMessagePoll", [("flags", flags as Any), ("pollId", pollId as Any), ("poll", poll as Any), ("results", results as Any)]) return ("updateMessagePoll", [("flags", flags as Any), ("pollId", pollId as Any), ("poll", poll as Any), ("results", results as Any)])
case .updateMessagePollVote(let pollId, let peer, let options, let qts): case .updateMessagePollVote(let pollId, let peer, let options, let qts):
return ("updateMessagePollVote", [("pollId", pollId as Any), ("peer", peer as Any), ("options", options as Any), ("qts", qts as Any)]) return ("updateMessagePollVote", [("pollId", pollId as Any), ("peer", peer as Any), ("options", options as Any), ("qts", qts as Any)])
case .updateMessageReactions(let flags, let peer, let msgId, let topMsgId, let reactions): case .updateMessageReactions(let flags, let peer, let msgId, let topMsgId, let savedPeerId, let reactions):
return ("updateMessageReactions", [("flags", flags as Any), ("peer", peer as Any), ("msgId", msgId as Any), ("topMsgId", topMsgId as Any), ("reactions", reactions as Any)]) return ("updateMessageReactions", [("flags", flags as Any), ("peer", peer as Any), ("msgId", msgId as Any), ("topMsgId", topMsgId as Any), ("savedPeerId", savedPeerId as Any), ("reactions", reactions as Any)])
case .updateMoveStickerSetToTop(let flags, let stickerset): case .updateMoveStickerSetToTop(let flags, let stickerset):
return ("updateMoveStickerSetToTop", [("flags", flags as Any), ("stickerset", stickerset as Any)]) return ("updateMoveStickerSetToTop", [("flags", flags as Any), ("stickerset", stickerset as Any)])
case .updateNewAuthorization(let flags, let hash, let date, let device, let location): case .updateNewAuthorization(let flags, let hash, let date, let device, let location):
@ -3367,16 +3369,21 @@ public extension Api {
_2 = reader.readInt64() _2 = reader.readInt64()
var _3: Int32? var _3: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() } if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
var _4: [Int32]? var _4: Api.Peer?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _5: [Int32]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) _5 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 { let _c5 = _5 != nil
return Api.Update.updateChannelReadMessagesContents(flags: _1!, channelId: _2!, topMsgId: _3, messages: _4!) if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.Update.updateChannelReadMessagesContents(flags: _1!, channelId: _2!, topMsgId: _3, savedPeerId: _4, messages: _5!)
} }
else { else {
return nil return nil
@ -4202,17 +4209,22 @@ public extension Api {
_3 = reader.readInt32() _3 = reader.readInt32()
var _4: Int32? var _4: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() } if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() }
var _5: Api.MessageReactions? var _5: Api.Peer?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _6: Api.MessageReactions?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.MessageReactions _6 = Api.parse(reader, signature: signature) as? Api.MessageReactions
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = _5 != nil let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 { let _c6 = _6 != nil
return Api.Update.updateMessageReactions(flags: _1!, peer: _2!, msgId: _3!, topMsgId: _4, reactions: _5!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.Update.updateMessageReactions(flags: _1!, peer: _2!, msgId: _3!, topMsgId: _4, savedPeerId: _5, reactions: _6!)
} }
else { else {
return nil return nil

View File

@ -7149,18 +7149,19 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func getUnreadReactions(flags: Int32, peer: Api.InputPeer, topMsgId: Int32?, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Messages>) { static func getUnreadReactions(flags: Int32, peer: Api.InputPeer, topMsgId: Int32?, savedPeerId: Api.InputPeer?, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Messages>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(841173339) buffer.appendInt32(-1115713364)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {savedPeerId!.serialize(buffer, true)}
serializeInt32(offsetId, buffer: buffer, boxed: false) serializeInt32(offsetId, buffer: buffer, boxed: false)
serializeInt32(addOffset, buffer: buffer, boxed: false) serializeInt32(addOffset, buffer: buffer, boxed: false)
serializeInt32(limit, buffer: buffer, boxed: false) serializeInt32(limit, buffer: buffer, boxed: false)
serializeInt32(maxId, buffer: buffer, boxed: false) serializeInt32(maxId, buffer: buffer, boxed: false)
serializeInt32(minId, buffer: buffer, boxed: false) serializeInt32(minId, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.getUnreadReactions", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("topMsgId", String(describing: topMsgId)), ("offsetId", String(describing: offsetId)), ("addOffset", String(describing: addOffset)), ("limit", String(describing: limit)), ("maxId", String(describing: maxId)), ("minId", String(describing: minId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in return (FunctionDescription(name: "messages.getUnreadReactions", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("topMsgId", String(describing: topMsgId)), ("savedPeerId", String(describing: savedPeerId)), ("offsetId", String(describing: offsetId)), ("addOffset", String(describing: addOffset)), ("limit", String(describing: limit)), ("maxId", String(describing: maxId)), ("minId", String(describing: minId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.messages.Messages? var result: Api.messages.Messages?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
@ -7479,13 +7480,14 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func readReactions(flags: Int32, peer: Api.InputPeer, topMsgId: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.AffectedHistory>) { static func readReactions(flags: Int32, peer: Api.InputPeer, topMsgId: Int32?, savedPeerId: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.AffectedHistory>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(1420459918) buffer.appendInt32(-1631301741)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.readReactions", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("topMsgId", String(describing: topMsgId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.AffectedHistory? in if Int(flags) & Int(1 << 1) != 0 {savedPeerId!.serialize(buffer, true)}
return (FunctionDescription(name: "messages.readReactions", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("topMsgId", String(describing: topMsgId)), ("savedPeerId", String(describing: savedPeerId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.AffectedHistory? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.messages.AffectedHistory? var result: Api.messages.AffectedHistory?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -67,7 +67,7 @@ enum AccountStateMutationOperation {
case DeleteMessages([MessageId]) case DeleteMessages([MessageId])
case EditMessage(MessageId, StoreMessage) case EditMessage(MessageId, StoreMessage)
case UpdateMessagePoll(MediaId, Api.Poll?, Api.PollResults) case UpdateMessagePoll(MediaId, Api.Poll?, Api.PollResults)
case UpdateMessageReactions(MessageId, Api.MessageReactions, Int32?) case UpdateMessageReactions(MessageId, Int64?, Api.MessageReactions, Int32?)
case UpdateMedia(MediaId, Media?) case UpdateMedia(MediaId, Media?)
case ReadInbox(MessageId) case ReadInbox(MessageId)
case ReadOutbox(MessageId, Int32?) case ReadOutbox(MessageId, Int32?)
@ -97,7 +97,7 @@ enum AccountStateMutationOperation {
case UpdatePinnedSavedItemIds(AccountStateUpdatePinnedItemIdsOperation) case UpdatePinnedSavedItemIds(AccountStateUpdatePinnedItemIdsOperation)
case UpdatePinnedTopic(peerId: PeerId, threadId: Int64, isPinned: Bool) case UpdatePinnedTopic(peerId: PeerId, threadId: Int64, isPinned: Bool)
case UpdatePinnedTopicOrder(peerId: PeerId, threadIds: [Int64]) case UpdatePinnedTopicOrder(peerId: PeerId, threadIds: [Int64])
case ReadMessageContents(peerIdsAndMessageIds: (PeerId?, [Int32]), date: Int32?) case ReadMessageContents(peerIdsAndMessageIds: (PeerId?, Int64?, [Int32]), date: Int32?)
case UpdateMessageImpressionCount(MessageId, Int32) case UpdateMessageImpressionCount(MessageId, Int32)
case UpdateMessageForwardsCount(MessageId, Int32) case UpdateMessageForwardsCount(MessageId, Int32)
case UpdateInstalledStickerPacks(AccountStateUpdateStickerPacksOperation) case UpdateInstalledStickerPacks(AccountStateUpdateStickerPacksOperation)
@ -376,8 +376,8 @@ struct AccountMutableState {
self.addOperation(.UpdateMessagePoll(id, poll, results)) self.addOperation(.UpdateMessagePoll(id, poll, results))
} }
mutating func updateMessageReactions(_ messageId: MessageId, reactions: Api.MessageReactions, eventTimestamp: Int32?) { mutating func updateMessageReactions(_ messageId: MessageId, threadId: Int64?, reactions: Api.MessageReactions, eventTimestamp: Int32?) {
self.addOperation(.UpdateMessageReactions(messageId, reactions, eventTimestamp)) self.addOperation(.UpdateMessageReactions(messageId, threadId, reactions, eventTimestamp))
} }
mutating func updateMedia(_ id: MediaId, media: Media?) { mutating func updateMedia(_ id: MediaId, media: Media?) {
@ -608,7 +608,7 @@ struct AccountMutableState {
self.addOperation(.UpdatePinnedTopicOrder(peerId: peerId, threadIds: threadIds)) self.addOperation(.UpdatePinnedTopicOrder(peerId: peerId, threadIds: threadIds))
} }
mutating func addReadMessagesContents(_ peerIdsAndMessageIds: (PeerId?, [Int32]), date: Int32?) { mutating func addReadMessagesContents(_ peerIdsAndMessageIds: (PeerId?, Int64?, [Int32]), date: Int32?) {
self.addOperation(.ReadMessageContents(peerIdsAndMessageIds: peerIdsAndMessageIds, date: date)) self.addOperation(.ReadMessageContents(peerIdsAndMessageIds: peerIdsAndMessageIds, date: date))
} }

View File

@ -821,7 +821,7 @@ func _internal_requestMessageHistoryThreads(accountPeerId: PeerId, postbox: Post
index: topicIndex, index: topicIndex,
threadPeer: threadPeer threadPeer: threadPeer
)) ))
case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _): case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadReactionsCount, _):
let isMarkedUnread = (flags & (1 << 3)) != 0 let isMarkedUnread = (flags & (1 << 3)) != 0
let data = MessageHistoryThreadData( let data = MessageHistoryThreadData(
creationDate: 0, creationDate: 0,
@ -871,7 +871,7 @@ func _internal_requestMessageHistoryThreads(accountPeerId: PeerId, postbox: Post
data: data, data: data,
topMessage: topMessage, topMessage: topMessage,
unreadMentionsCount: 0, unreadMentionsCount: 0,
unreadReactionsCount: 0, unreadReactionsCount: unreadReactionsCount,
index: topicIndex, index: topicIndex,
threadPeer: threadPeer threadPeer: threadPeer
)) ))

View File

@ -1538,10 +1538,15 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
let isPinned = (flags & (1 << 0)) != 0 let isPinned = (flags & (1 << 0)) != 0
updatedState.addUpdatePinnedTopic(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: Int64(topicId), isPinned: isPinned) updatedState.addUpdatePinnedTopic(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: Int64(topicId), isPinned: isPinned)
case let .updateReadMessagesContents(_, messages, _, _, date): case let .updateReadMessagesContents(_, messages, _, _, date):
updatedState.addReadMessagesContents((nil, messages), date: date) updatedState.addReadMessagesContents((nil, nil, messages), date: date)
case let .updateChannelReadMessagesContents(_, channelId, topMsgId, messages): case let .updateChannelReadMessagesContents(_, channelId, topMsgId, savedPeerId, messages):
let _ = topMsgId var threadId: Int64?
updatedState.addReadMessagesContents((PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), messages), date: nil) if let savedPeerId {
threadId = savedPeerId.peerId.toInt64()
} else if let topMsgId {
threadId = Int64(topMsgId)
}
updatedState.addReadMessagesContents((PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId, messages), date: nil)
case let .updateChannelMessageViews(channelId, id, views): case let .updateChannelMessageViews(channelId, id, views):
updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: id), count: views) updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: id), count: views)
/*case let .updateChannelMessageForwards(channelId, id, forwards): /*case let .updateChannelMessageForwards(channelId, id, forwards):
@ -1794,8 +1799,15 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
return current return current
} }
}) })
case let .updateMessageReactions(_, peer, msgId, _, reactions): case let .updateMessageReactions(_, peer, msgId, topMsgId, savedPeerId, reactions):
updatedState.updateMessageReactions(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: msgId), reactions: reactions, eventTimestamp: updatesDate) var threadId: Int64?
if let savedPeerId {
threadId = savedPeerId.peerId.toInt64()
} else if let topMsgId {
threadId = Int64(topMsgId)
}
updatedState.updateMessageReactions(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: msgId), threadId: threadId, reactions: reactions, eventTimestamp: updatesDate)
case .updateAttachMenuBots: case .updateAttachMenuBots:
updatedState.addUpdateAttachMenuBots() updatedState.addUpdateAttachMenuBots()
case let .updateWebViewResultSent(queryId): case let .updateWebViewResultSent(queryId):
@ -2108,8 +2120,7 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
} }
case let .savedDialog(savedDialog): case let .savedDialog(savedDialog):
switch savedDialog { switch savedDialog {
case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _): case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadReactionsCount, _):
state.operations.append(.ResetForumTopic( state.operations.append(.ResetForumTopic(
topicId: PeerAndBoundThreadId(peerId: peerId, threadId: peer.peerId.toInt64()), topicId: PeerAndBoundThreadId(peerId: peerId, threadId: peer.peerId.toInt64()),
data: StoreMessageHistoryThreadData( data: StoreMessageHistoryThreadData(
@ -2133,7 +2144,7 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
), ),
topMessageId: topMessage, topMessageId: topMessage,
unreadMentionCount: 0, unreadMentionCount: 0,
unreadReactionCount: 0 unreadReactionCount: unreadReactionsCount
), ),
pts: result.pts pts: result.pts
)) ))
@ -2268,7 +2279,7 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
} }
case let .savedDialog(savedDialog): case let .savedDialog(savedDialog):
switch savedDialog { switch savedDialog {
case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _): case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadReactionsCount, _):
let data = MessageHistoryThreadData( let data = MessageHistoryThreadData(
creationDate: 0, creationDate: 0,
isOwnedByMe: true, isOwnedByMe: true,
@ -2292,7 +2303,7 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
} }
transaction.replaceMessageTagSummary(peerId: peerId, threadId: peer.peerId.toInt64(), tagMask: .unseenPersonalMessage, namespace: Namespaces.Message.Cloud, customTag: nil, count: 0, maxId: topMessage) transaction.replaceMessageTagSummary(peerId: peerId, threadId: peer.peerId.toInt64(), tagMask: .unseenPersonalMessage, namespace: Namespaces.Message.Cloud, customTag: nil, count: 0, maxId: topMessage)
transaction.replaceMessageTagSummary(peerId: peerId, threadId: peer.peerId.toInt64(), tagMask: .unseenReaction, namespace: Namespaces.Message.Cloud, customTag: nil, count: 0, maxId: topMessage) transaction.replaceMessageTagSummary(peerId: peerId, threadId: peer.peerId.toInt64(), tagMask: .unseenReaction, namespace: Namespaces.Message.Cloud, customTag: nil, count: unreadReactionsCount, maxId: topMessage)
case .savedDialog: case .savedDialog:
break break
} }
@ -2429,7 +2440,7 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
} }
case let .savedDialog(savedDialog): case let .savedDialog(savedDialog):
switch savedDialog { switch savedDialog {
case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _): case let .monoForumDialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadReactionsCount, _):
fetchedChatList.threadInfos[PeerAndBoundThreadId(peerId: peerId, threadId: peer.peerId.toInt64())] = StoreMessageHistoryThreadData( fetchedChatList.threadInfos[PeerAndBoundThreadId(peerId: peerId, threadId: peer.peerId.toInt64())] = StoreMessageHistoryThreadData(
data: MessageHistoryThreadData( data: MessageHistoryThreadData(
@ -2452,7 +2463,7 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
), ),
topMessageId: topMessage, topMessageId: topMessage,
unreadMentionCount: 0, unreadMentionCount: 0,
unreadReactionCount: 0 unreadReactionCount: unreadReactionsCount
) )
case .savedDialog: case .savedDialog:
break break
@ -2618,7 +2629,7 @@ private func messagesFromOperations(state: AccountMutableState) -> [StoreMessage
private func reactionsFromState(_ state: AccountMutableState) -> [MessageReaction.Reaction] { private func reactionsFromState(_ state: AccountMutableState) -> [MessageReaction.Reaction] {
var result: [MessageReaction.Reaction] = [] var result: [MessageReaction.Reaction] = []
for operation in state.operations { for operation in state.operations {
if case let .UpdateMessageReactions(_, reactions, _) = operation { if case let .UpdateMessageReactions(_, _, reactions, _) = operation {
for reaction in ReactionsMessageAttribute(apiReactions: reactions).reactions { for reaction in ReactionsMessageAttribute(apiReactions: reactions).reactions {
result.append(reaction.value) result.append(reaction.value)
} }
@ -3303,9 +3314,14 @@ private func pollChannel(accountPeerId: PeerId, postbox: Postbox, network: Netwo
updatedState.updateMessagesPinned(ids: messages.map { id in updatedState.updateMessagesPinned(ids: messages.map { id in
MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id) MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id)
}, pinned: (flags & (1 << 0)) != 0) }, pinned: (flags & (1 << 0)) != 0)
case let .updateChannelReadMessagesContents(_, _, topMsgId, messages): case let .updateChannelReadMessagesContents(_, _, topMsgId, savedPeerId, messages):
let _ = topMsgId var threadId: Int64?
updatedState.addReadMessagesContents((peer.id, messages), date: nil) if let savedPeerId {
threadId = savedPeerId.peerId.toInt64()
} else if let topMsgId {
threadId = Int64(topMsgId)
}
updatedState.addReadMessagesContents((peer.id, threadId, messages), date: nil)
case let .updateChannelMessageViews(_, id, views): case let .updateChannelMessageViews(_, id, views):
updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id), count: views) updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id), count: views)
case let .updateChannelWebPage(_, apiWebpage, _, _): case let .updateChannelWebPage(_, apiWebpage, _, _):
@ -4677,7 +4693,7 @@ func replayFinalState(
case let .UpdatePinnedTopicOrder(peerId, threadIds): case let .UpdatePinnedTopicOrder(peerId, threadIds):
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: threadIds) transaction.setPeerPinnedThreads(peerId: peerId, threadIds: threadIds)
case let .ReadMessageContents(peerIdAndMessageIds, date): case let .ReadMessageContents(peerIdAndMessageIds, date):
let (peerId, messageIds) = peerIdAndMessageIds let (peerId, _, messageIds) = peerIdAndMessageIds
if let peerId = peerId { if let peerId = peerId {
for id in messageIds { for id in messageIds {
@ -4867,7 +4883,7 @@ func replayFinalState(
return state return state
}) })
} }
case let .UpdateMessageReactions(messageId, reactions, _): case let .UpdateMessageReactions(messageId, _, reactions, _):
transaction.updateMessage(messageId, update: { currentMessage in transaction.updateMessage(messageId, update: { currentMessage in
var updatedReactions = ReactionsMessageAttribute(apiReactions: reactions) var updatedReactions = ReactionsMessageAttribute(apiReactions: reactions)

View File

@ -870,7 +870,7 @@ public final class AccountViewTracker {
} }
for update in updateList { for update in updateList {
switch update { switch update {
case let .updateMessageReactions(_, peer, msgId, _, reactions): case let .updateMessageReactions(_, peer, msgId, _, _, reactions):
transaction.updateMessage(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: msgId), update: { currentMessage in transaction.updateMessage(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: msgId), update: { currentMessage in
var updatedReactions = ReactionsMessageAttribute(apiReactions: reactions) var updatedReactions = ReactionsMessageAttribute(apiReactions: reactions)
@ -1689,7 +1689,7 @@ public final class AccountViewTracker {
} }
transaction.replaceMessageTagSummary(peerId: peerId, threadId: threadId, tagMask: .unseenReaction, namespace: Namespaces.Message.Cloud, customTag: nil, count: 0, maxId: maxId) transaction.replaceMessageTagSummary(peerId: peerId, threadId: threadId, tagMask: .unseenReaction, namespace: Namespaces.Message.Cloud, customTag: nil, count: 0, maxId: maxId)
addSynchronizeMarkAllUnseenReactionsOperation(transaction: transaction, peerId: peerId, maxId: summary.range.maxId) addSynchronizeMarkAllUnseenReactionsOperation(transaction: transaction, peerId: peerId, maxId: summary.range.maxId, threadId: threadId)
} }
return ids return ids

View File

@ -539,7 +539,7 @@ private func validateChannelMessagesBatch(postbox: Postbox, network: Network, ac
if tag == MessageTags.unseenPersonalMessage { if tag == MessageTags.unseenPersonalMessage {
requestSignal = network.request(Api.functions.messages.getUnreadMentions(flags: 0, peer: inputPeer, topMsgId: nil, offsetId: messageIds[messageIds.count - 1].id + 1, addOffset: 0, limit: Int32(messageIds.count), maxId: messageIds[messageIds.count - 1].id + 1, minId: messageIds[0].id - 1)) requestSignal = network.request(Api.functions.messages.getUnreadMentions(flags: 0, peer: inputPeer, topMsgId: nil, offsetId: messageIds[messageIds.count - 1].id + 1, addOffset: 0, limit: Int32(messageIds.count), maxId: messageIds[messageIds.count - 1].id + 1, minId: messageIds[0].id - 1))
} else if tag == MessageTags.unseenReaction { } else if tag == MessageTags.unseenReaction {
requestSignal = network.request(Api.functions.messages.getUnreadReactions(flags: 0, peer: inputPeer, topMsgId: nil, offsetId: messageIds[messageIds.count - 1].id + 1, addOffset: 0, limit: Int32(messageIds.count), maxId: messageIds[messageIds.count - 1].id + 1, minId: messageIds[0].id - 1)) requestSignal = network.request(Api.functions.messages.getUnreadReactions(flags: 0, peer: inputPeer, topMsgId: nil, savedPeerId: nil, offsetId: messageIds[messageIds.count - 1].id + 1, addOffset: 0, limit: Int32(messageIds.count), maxId: messageIds[messageIds.count - 1].id + 1, minId: messageIds[0].id - 1))
} else if let filter = messageFilterForTagMask(tag) { } else if let filter = messageFilterForTagMask(tag) {
requestSignal = network.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, savedPeerId: nil, savedReaction: nil, topMsgId: nil, filter: filter, minDate: 0, maxDate: 0, offsetId: messageIds[messageIds.count - 1].id + 1, addOffset: 0, limit: Int32(messageIds.count), maxId: messageIds[messageIds.count - 1].id + 1, minId: messageIds[0].id - 1, hash: hash)) requestSignal = network.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, savedPeerId: nil, savedReaction: nil, topMsgId: nil, filter: filter, minDate: 0, maxDate: 0, offsetId: messageIds[messageIds.count - 1].id + 1, addOffset: 0, limit: Int32(messageIds.count), maxId: messageIds[messageIds.count - 1].id + 1, minId: messageIds[0].id - 1, hash: hash))
} else { } else {

View File

@ -718,8 +718,16 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
flags |= (1 << 0) flags |= (1 << 0)
topMsgId = Int32(clamping: threadId) topMsgId = Int32(clamping: threadId)
} }
var savedPeerId: Api.InputPeer?
if let subPeerId = peerInput.requestSubPeerId(accountPeerId: accountPeerId, peer: peer), let subPeer = subPeer, subPeer.id == subPeerId {
flags |= (1 << 1)
if let inputPeer = apiInputPeer(subPeer) {
flags |= 1 << 2
savedPeerId = inputPeer
}
}
request = source.request(Api.functions.messages.getUnreadReactions(flags: flags, peer: inputPeer, topMsgId: topMsgId, offsetId: offsetId, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId)) request = source.request(Api.functions.messages.getUnreadReactions(flags: flags, peer: inputPeer, topMsgId: topMsgId, savedPeerId: savedPeerId, offsetId: offsetId, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId))
} else if tag == .liveLocation { } else if tag == .liveLocation {
let selectedLimit = count let selectedLimit = count

View File

@ -280,11 +280,29 @@ func managedSynchronizeMarkAllUnseenReactionsOperations(postbox: Postbox, networ
} }
private func synchronizeMarkAllUnseenReactions(transaction: Transaction, postbox: Postbox, network: Network, stateManager: AccountStateManager, peerId: PeerId, operation: SynchronizeMarkAllUnseenReactionsOperation) -> Signal<Void, NoError> { private func synchronizeMarkAllUnseenReactions(transaction: Transaction, postbox: Postbox, network: Network, stateManager: AccountStateManager, peerId: PeerId, operation: SynchronizeMarkAllUnseenReactionsOperation) -> Signal<Void, NoError> {
guard let inputPeer = transaction.getPeer(peerId).flatMap(apiInputPeer) else { guard let peer = transaction.getPeer(peerId) else {
return .complete()
}
guard let inputPeer = apiInputPeer(peer) else {
return .complete() return .complete()
} }
let signal = network.request(Api.functions.messages.readReactions(flags: 0, peer: inputPeer, topMsgId: nil)) var flags: Int32 = 0
var topMsgId: Int32?
var savedPeerId: Api.InputPeer?
if let threadId = operation.threadId {
if peer.isMonoForum {
if let subPeerId = transaction.getPeer(PeerId(threadId)).flatMap(apiInputPeer) {
flags |= 1 << 1
savedPeerId = subPeerId
}
} else {
flags |= 1 << 0
topMsgId = Int32(clamping: threadId)
}
}
let signal = network.request(Api.functions.messages.readReactions(flags: flags, peer: inputPeer, topMsgId: topMsgId, savedPeerId: savedPeerId))
|> map(Optional.init) |> map(Optional.init)
|> `catch` { _ -> Signal<Api.messages.AffectedHistory?, Bool> in |> `catch` { _ -> Signal<Api.messages.AffectedHistory?, Bool> in
return .fail(true) return .fail(true)

View File

@ -25,13 +25,13 @@ func addSynchronizeMarkAllUnseenPersonalMessagesOperation(transaction: Transacti
transaction.operationLogAddEntry(peerId: peerId, tag: tag, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: SynchronizeMarkAllUnseenPersonalMessagesOperation(maxId: maxId)) transaction.operationLogAddEntry(peerId: peerId, tag: tag, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: SynchronizeMarkAllUnseenPersonalMessagesOperation(maxId: maxId))
} }
func addSynchronizeMarkAllUnseenReactionsOperation(transaction: Transaction, peerId: PeerId, maxId: MessageId.Id) { func addSynchronizeMarkAllUnseenReactionsOperation(transaction: Transaction, peerId: PeerId, maxId: MessageId.Id, threadId: Int64?) {
let tag: PeerOperationLogTag = OperationLogTags.SynchronizeMarkAllUnseenReactions let tag: PeerOperationLogTag = OperationLogTags.SynchronizeMarkAllUnseenReactions
var topLocalIndex: Int32? var topLocalIndex: Int32?
var currentMaxId: MessageId.Id? var currentMaxId: MessageId.Id?
transaction.operationLogEnumerateEntries(peerId: peerId, tag: tag, { entry in transaction.operationLogEnumerateEntries(peerId: peerId, tag: tag, { entry in
topLocalIndex = entry.tagLocalIndex topLocalIndex = entry.tagLocalIndex
if let operation = entry.contents as? SynchronizeMarkAllUnseenReactionsOperation { if let operation = entry.contents as? SynchronizeMarkAllUnseenReactionsOperation, operation.threadId == threadId {
currentMaxId = operation.maxId currentMaxId = operation.maxId
} }
return false return false
@ -44,5 +44,5 @@ func addSynchronizeMarkAllUnseenReactionsOperation(transaction: Transaction, pee
let _ = transaction.operationLogRemoveEntry(peerId: peerId, tag: tag, tagLocalIndex: topLocalIndex) let _ = transaction.operationLogRemoveEntry(peerId: peerId, tag: tag, tagLocalIndex: topLocalIndex)
} }
transaction.operationLogAddEntry(peerId: peerId, tag: tag, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: SynchronizeMarkAllUnseenReactionsOperation(maxId: maxId)) transaction.operationLogAddEntry(peerId: peerId, tag: tag, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: SynchronizeMarkAllUnseenReactionsOperation(threadId: threadId, maxId: maxId))
} }

View File

@ -17,17 +17,25 @@ public final class SynchronizeMarkAllUnseenPersonalMessagesOperation: PostboxCod
} }
public final class SynchronizeMarkAllUnseenReactionsOperation: PostboxCoding { public final class SynchronizeMarkAllUnseenReactionsOperation: PostboxCoding {
public let threadId: Int64?
public let maxId: MessageId.Id public let maxId: MessageId.Id
public init(maxId: MessageId.Id) { public init(threadId: Int64?, maxId: MessageId.Id) {
self.threadId = threadId
self.maxId = maxId self.maxId = maxId
} }
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
self.threadId = decoder.decodeOptionalInt64ForKey("threadId")
self.maxId = decoder.decodeInt32ForKey("maxId", orElse: Int32.min + 1) self.maxId = decoder.decodeInt32ForKey("maxId", orElse: Int32.min + 1)
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
if let threadId = self.threadId {
encoder.encodeInt64(threadId, forKey: "threadId")
} else {
encoder.encodeNil(forKey: "threadId")
}
encoder.encodeInt32(self.maxId, forKey: "maxId") encoder.encodeInt32(self.maxId, forKey: "maxId")
} }
} }