Skip to content

Commit 9a305d3

Browse files
authored
Self info message on end poll
1 parent 29a24f0 commit 9a305d3

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

Signal/translations/en.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6541,6 +6541,9 @@
65416541
/* Shown when another user ends a poll. Embeds {{ another user }} and {{ poll question }}. */
65426542
"POLL_ENDED_BY_OTHER_CHAT_LIST_UPDATE" = "%@ ended the poll: %@";
65436543

6544+
/* Shown when the local user ends a poll. Embeds {{ poll question }}. */
6545+
"POLL_ENDED_BY_YOU_CHAT_LIST_UPDATE" = "You ended the poll: %@";
6546+
65446547
/* Notification that {{contact}} ended a poll with question {{poll question}} */
65456548
"POLL_ENDED_NOTIFICATION" = "%@ ended the poll “%@”";
65466549

SignalServiceKit/Messages/Interactions/Polls/OutgoingPollTerminate.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class OutgoingPollTerminateMessage: TSOutgoingMessage {
9696

9797
try PollStore().revertPollTerminate(interactionId: interactionId, transaction: tx)
9898

99+
// TODO: delete info message.
100+
99101
SSKEnvironment.shared.databaseStorageRef.touch(interaction: targetMessage, shouldReindex: false, tx: tx)
100102
} catch {
101103
Logger.error("Failed to revert poll terminate: \(error)")

SignalServiceKit/Messages/Interactions/Polls/PollMessageManager.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ public class PollMessageManager {
254254
message: preparedMessage,
255255
transaction: tx
256256
)
257+
258+
guard let localAci = accountManager.localIdentifiers(tx: tx)?.aci else {
259+
throw OWSAssertionError("User not registered")
260+
}
261+
262+
insertInfoMessageForEndPoll(
263+
timestamp: Date().ows_millisecondsSince1970,
264+
groupThread: thread,
265+
targetPollTimestamp: targetPoll.timestamp,
266+
pollQuestion: poll.question,
267+
terminateAuthor: localAci,
268+
tx: tx
269+
)
257270
}
258271
}
259272

SignalServiceKit/Messages/Interactions/Polls/TSInfoMessage+Polls.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ extension TSInfoMessage {
8282
return nil
8383
}
8484

85+
guard let localAci = DependenciesBridge.shared.tsAccountManager.localIdentifiers(tx: transaction)?.aci else {
86+
Logger.error("Can't find local ACI")
87+
return nil
88+
}
89+
8590
var pollTerminateAci: Aci?
8691
do {
8792
pollTerminateAci = try Aci.parseFrom(serviceIdBinary: endPollItem.authorServiceIdBinary)
@@ -95,6 +100,14 @@ extension TSInfoMessage {
95100
return nil
96101
}
97102

103+
if localAci == pollTerminateAci {
104+
let formatString = OWSLocalizedString(
105+
"POLL_ENDED_BY_YOU_CHAT_LIST_UPDATE",
106+
comment: "Shown when the local user ends a poll. Embeds {{ poll question }}."
107+
)
108+
return String(format: formatString, question)
109+
}
110+
98111
let displayName = SSKEnvironment.shared.contactManagerRef.displayName(
99112
for: SignalServiceAddress(pollTerminateAci),
100113
tx: transaction

0 commit comments

Comments
 (0)