@@ -1055,8 +1055,42 @@ public final class MessageReceiver {
10551055 return nil
10561056 }
10571057
1058+ if let pollVote = dataMessage. pollVote {
1059+ do {
1060+ guard let ( targetMessage, shouldNotifyAuthorOfVote) = try DependenciesBridge . shared. pollMessageManager. processIncomingPollVote (
1061+ voteAuthor: envelope. sourceAci,
1062+ pollVoteProto: pollVote,
1063+ transaction: tx
1064+ ) else {
1065+ Logger . error ( " error processing poll vote! " )
1066+ return nil
1067+ }
1068+
1069+ // Update interaction in the conversation view
1070+ SSKEnvironment . shared. databaseStorageRef. touch ( interaction: targetMessage, shouldReindex: false , tx: tx)
1071+
1072+ if shouldNotifyAuthorOfVote {
1073+ // If this is not an unvote, the user is the poll creator and the vote isn't authored by them, send a notification.
1074+ if let outgoingMessage = targetMessage as? TSOutgoingMessage {
1075+ SSKEnvironment . shared. notificationPresenterRef. notifyUserOfPollVote (
1076+ forMessage: outgoingMessage,
1077+ voteAuthor: envelope. sourceAci,
1078+ thread: thread,
1079+ transaction: tx
1080+ )
1081+ }
1082+ }
1083+ } catch {
1084+ owsFailDebug ( " Could not insert poll vote! " )
1085+ return nil
1086+ }
1087+
1088+ // Don't store PollVote as a message.
1089+ return nil
1090+ }
1091+
10581092 if request. shouldDiscardVisibleMessages {
1059- // Now that "reactions" and "delete for everyone" have been processed, the
1093+ // Now that "poll votes", " reactions" and "delete for everyone" have been processed, the
10601094 // only possible outcome of further processing is a visible message or
10611095 // group call update, both of which should be discarded.
10621096 Logger . info ( " Discarding message w/ts \( envelope. timestamp) " )
@@ -1279,40 +1313,6 @@ public final class MessageReceiver {
12791313 return nil
12801314 }
12811315
1282- if let pollVote = dataMessage. pollVote {
1283- do {
1284- guard let ( targetMessage, shouldNotifyAuthorOfVote) = try DependenciesBridge . shared. pollMessageManager. processIncomingPollVote (
1285- voteAuthor: envelope. sourceAci,
1286- pollVoteProto: pollVote,
1287- transaction: tx
1288- ) else {
1289- Logger . error ( " error processing poll vote! " )
1290- return nil
1291- }
1292-
1293- // Update interaction in the conversation view
1294- SSKEnvironment . shared. databaseStorageRef. touch ( interaction: targetMessage, shouldReindex: false , tx: tx)
1295-
1296- if shouldNotifyAuthorOfVote {
1297- // If this is not an unvote, the user is the poll creator and the vote isn't authored by them, send a notification.
1298- if let outgoingMessage = targetMessage as? TSOutgoingMessage {
1299- SSKEnvironment . shared. notificationPresenterRef. notifyUserOfPollVote (
1300- forMessage: outgoingMessage,
1301- voteAuthor: envelope. sourceAci,
1302- thread: thread,
1303- transaction: tx
1304- )
1305- }
1306- }
1307- } catch {
1308- owsFailDebug ( " Could not insert poll vote! " )
1309- return nil
1310- }
1311-
1312- // Don't store PollVote as a message.
1313- return nil
1314- }
1315-
13161316 // Legit usage of senderTimestamp when creating an incoming group message
13171317 // record.
13181318 let messageBuilder = TSIncomingMessageBuilder (
0 commit comments