pass iscreator

This commit is contained in:
Mikhail Filimonov 2026-03-23 10:45:34 +01:00
parent 5ed2f0ad1e
commit 7354bea3e6
3 changed files with 13 additions and 4 deletions

View file

@ -472,6 +472,7 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
let revotingDisabled = (flags & (1 << 7)) != 0
let shuffleAnswers = (flags & (1 << 8)) != 0
let hideResultsUntilClose = (flags & (1 << 9)) != 0
let isCreator = (flags & (1 << 10)) != 0
let questionText: String
let questionEntities: [MessageTextEntity]
@ -486,7 +487,7 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
if let apiAttachedMedia = messageMediaPollData.attachedMedia {
parsedAttachedMedia = textMediaAndExpirationTimerFromApiMedia(apiAttachedMedia, peerId).media
}
return (TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, deadlineDate: closeDate, pollHash: pollHash, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, attachedMedia: parsedAttachedMedia), nil, nil, nil, nil, nil)
return (TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, deadlineDate: closeDate, pollHash: pollHash, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, isCreator: isCreator, attachedMedia: parsedAttachedMedia), nil, nil, nil, nil, nil)
}
case let .messageMediaToDo(messageMediaToDoData):
let (todo, completions) = (messageMediaToDoData.todo, messageMediaToDoData.completions)

View file

@ -4517,6 +4517,7 @@ func replayFinalState(
let revotingDisabled = (flags & (1 << 7)) != 0
let shuffleAnswers = (flags & (1 << 8)) != 0
let hideResultsUntilClose = (flags & (1 << 9)) != 0
let isCreator = (flags & (1 << 10)) != 0
let questionText: String
let questionEntities: [MessageTextEntity]
@ -4527,7 +4528,7 @@ func replayFinalState(
questionEntities = messageTextEntitiesFromApiEntities(entities)
}
updatedPoll = TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: poll.results, isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, deadlineDate: closeDate, pollHash: pollHash, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, attachedMedia: poll.attachedMedia)
updatedPoll = TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: poll.results, isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, deadlineDate: closeDate, pollHash: pollHash, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, isCreator: isCreator, attachedMedia: poll.attachedMedia)
}
}
updatedPoll = updatedPoll.withUpdatedResults(TelegramMediaPollResults(apiResults: results), min: resultsMin)

View file

@ -258,9 +258,10 @@ public final class TelegramMediaPoll: Media, Equatable {
public let revotingDisabled: Bool
public let shuffleAnswers: Bool
public let hideResultsUntilClose: Bool
public let isCreator: Bool
public let attachedMedia: Media?
public init(pollId: MediaId, publicity: TelegramMediaPollPublicity, kind: TelegramMediaPollKind, text: String, textEntities: [MessageTextEntity], options: [TelegramMediaPollOption], correctAnswers: [Data]?, results: TelegramMediaPollResults, isClosed: Bool, deadlineTimeout: Int32?, deadlineDate: Int32?, pollHash: Int64, openAnswers: Bool = false, revotingDisabled: Bool = false, shuffleAnswers: Bool = false, hideResultsUntilClose: Bool = false, attachedMedia: Media? = nil) {
public init(pollId: MediaId, publicity: TelegramMediaPollPublicity, kind: TelegramMediaPollKind, text: String, textEntities: [MessageTextEntity], options: [TelegramMediaPollOption], correctAnswers: [Data]?, results: TelegramMediaPollResults, isClosed: Bool, deadlineTimeout: Int32?, deadlineDate: Int32?, pollHash: Int64, openAnswers: Bool = false, revotingDisabled: Bool = false, shuffleAnswers: Bool = false, hideResultsUntilClose: Bool = false, isCreator: Bool = false, attachedMedia: Media? = nil) {
self.pollId = pollId
self.publicity = publicity
self.kind = kind
@ -277,6 +278,7 @@ public final class TelegramMediaPoll: Media, Equatable {
self.revotingDisabled = revotingDisabled
self.shuffleAnswers = shuffleAnswers
self.hideResultsUntilClose = hideResultsUntilClose
self.isCreator = isCreator
self.attachedMedia = attachedMedia
}
@ -301,6 +303,7 @@ public final class TelegramMediaPoll: Media, Equatable {
self.revotingDisabled = decoder.decodeInt32ForKey("rd", orElse: 0) != 0
self.shuffleAnswers = decoder.decodeInt32ForKey("sa", orElse: 0) != 0
self.hideResultsUntilClose = decoder.decodeInt32ForKey("hr", orElse: 0) != 0
self.isCreator = decoder.decodeInt32ForKey("cr", orElse: 0) != 0
self.attachedMedia = decoder.decodeObjectForKey("am") as? Media
}
@ -335,6 +338,7 @@ public final class TelegramMediaPoll: Media, Equatable {
encoder.encodeInt32(self.revotingDisabled ? 1 : 0, forKey: "rd")
encoder.encodeInt32(self.shuffleAnswers ? 1 : 0, forKey: "sa")
encoder.encodeInt32(self.hideResultsUntilClose ? 1 : 0, forKey: "hr")
encoder.encodeInt32(self.isCreator ? 1 : 0, forKey: "cr")
if let attachedMedia = self.attachedMedia {
encoder.encodeObject(attachedMedia, forKey: "am")
} else {
@ -402,6 +406,9 @@ public final class TelegramMediaPoll: Media, Equatable {
if lhs.hideResultsUntilClose != rhs.hideResultsUntilClose {
return false
}
if lhs.isCreator != rhs.isCreator {
return false
}
if let lhsMedia = lhs.attachedMedia, let rhsMedia = rhs.attachedMedia {
if !lhsMedia.isEqual(to: rhsMedia) { return false }
} else if (lhs.attachedMedia == nil) != (rhs.attachedMedia == nil) {
@ -435,6 +442,6 @@ public final class TelegramMediaPoll: Media, Equatable {
} else {
updatedResults = results
}
return TelegramMediaPoll(pollId: self.pollId, publicity: self.publicity, kind: self.kind, text: self.text, textEntities: self.textEntities, options: self.options, correctAnswers: self.correctAnswers, results: updatedResults, isClosed: self.isClosed, deadlineTimeout: self.deadlineTimeout, deadlineDate: self.deadlineDate, pollHash: self.pollHash, openAnswers: self.openAnswers, revotingDisabled: self.revotingDisabled, shuffleAnswers: self.shuffleAnswers, hideResultsUntilClose: self.hideResultsUntilClose, attachedMedia: self.attachedMedia)
return TelegramMediaPoll(pollId: self.pollId, publicity: self.publicity, kind: self.kind, text: self.text, textEntities: self.textEntities, options: self.options, correctAnswers: self.correctAnswers, results: updatedResults, isClosed: self.isClosed, deadlineTimeout: self.deadlineTimeout, deadlineDate: self.deadlineDate, pollHash: self.pollHash, openAnswers: self.openAnswers, revotingDisabled: self.revotingDisabled, shuffleAnswers: self.shuffleAnswers, hideResultsUntilClose: self.hideResultsUntilClose, isCreator: self.isCreator, attachedMedia: self.attachedMedia)
}
}