Skip to content

Commit 94a283b

Browse files
Backend/notifs: Remove deprecated notification_data.ChatMessage.message (#9118)
1 parent a568f16 commit 94a283b

3 files changed

Lines changed: 12 additions & 39 deletions

File tree

app/backend/src/couchers/email/emails.py

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,11 @@ def get_body_blocks(self, loc_context: LocalizationContext) -> list[EmailBlock]:
281281

282282
@classmethod
283283
def from_notification(cls, data: notification_data_pb2.ChatMessage, *, user_name: str) -> Self:
284-
group_chat_title: str | None = data.group_chat_title
285-
if not group_chat_title:
286-
# Backcompat (2026-05): The group name previously was formatted in the message string
287-
# msg = f"{message.author.name} sent a message in {group_chat.title}"
288-
if match := re.search(" sent a message in (.+)$", data.message or ""):
289-
group_chat_title = match[1]
290-
else:
291-
group_chat_title = None
292-
293284
return cls(
294285
user_name,
295286
author=UserInfo.from_protobuf(data.author),
296287
text=data.text,
297-
group_chat_title=group_chat_title,
288+
group_chat_title=data.group_chat_title,
298289
view_url=urls.chat_link(chat_id=data.group_chat_id),
299290
)
300291

@@ -350,33 +341,16 @@ def get_body_blocks(self, loc_context: LocalizationContext) -> list[EmailBlock]:
350341

351342
@classmethod
352343
def from_notification(cls, data: notification_data_pb2.ChatMissedMessages, *, user_name: str) -> Self:
353-
missed_entries = []
354-
for message in data.messages:
355-
group_chat_title: str | None = message.group_chat_title
356-
missed_count: int = message.unseen_count
357-
358-
# Backcompat (2026-05): The group name and unseen count were previously was formatted in the message string
359-
# msg = f"You missed {unseen_count} message(s) in {group_chat.title}"
360-
if not group_chat_title or not missed_count:
361-
if match := re.search(" message(s) in (.+)$", message.message or ""):
362-
group_chat_title = match[1]
363-
else:
364-
group_chat_title = None
365-
366-
if match := re.search(r"^You missed (\d+) message(s)", message.message or ""):
367-
missed_count = int(match[1])
368-
else:
369-
missed_count = 1
370-
371-
missed_entries.append(
372-
cls.Entry(
373-
group_chat_title=group_chat_title,
374-
missed_count=missed_count,
375-
latest_message_author=UserInfo.from_protobuf(message.author),
376-
latest_message_text=message.text,
377-
view_url=urls.chat_link(chat_id=message.group_chat_id),
378-
)
344+
missed_entries = [
345+
cls.Entry(
346+
group_chat_title=message.group_chat_title,
347+
missed_count=message.unseen_count,
348+
latest_message_author=UserInfo.from_protobuf(message.author),
349+
latest_message_text=message.text,
350+
view_url=urls.chat_link(chat_id=message.group_chat_id),
379351
)
352+
for message in data.messages
353+
]
380354

381355
return cls(user_name, entries=missed_entries)
382356

app/backend/src/tests/test_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ def test_chat_missed_messages_list_unsubscribe_header(db, email_collector: Email
450450
messages=[
451451
notification_data_pb2.ChatMessage(
452452
author=api_pb2.User(name="Test User", user_id=2, username="testuser"),
453-
message="You missed 1 message(s) from Test User",
454453
text="Hello!",
455454
group_chat_id=99,
455+
unseen_count=1,
456456
),
457457
],
458458
),

app/proto/notification_data.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ message EventDelete {
150150

151151
message ChatMessage {
152152
org.couchers.api.core.User author = 1;
153-
// Obsolete (2026-05): Was not i18n-friendly. Use group_chat_title. Kept for handling fallback.
154-
string message = 2 [deprecated = true];
153+
reserved 2; // Formerly "message", non-localized.
155154
string text = 3;
156155
uint64 group_chat_id = 4;
157156
string group_chat_title = 5; // Empty for direct messages

0 commit comments

Comments
 (0)