Repository: zulip/zulip

Issue:
Rename `subject_links` to `topic_links` in our API
This is an element of the broader `subject` -> `topic` migration (see #1192) that should be straightforward to change, because I believe the mobile apps don't access `subject_links` yet, so there's no compatibility work required.  (What the data is used for in the webapp is the little in-topic-field links we show when there is a link or linkifier matching the topic line of the message).

@gnprice to confirm I'm reading the mobile codebase correctly that it's indeed not accessed.

Noticed in #13587; tagging as a priority since this sort of API migration gets more complex when delayed.  We should be sure to look again at updating the docs as discussed in #13587 once this is complete.


Discussion:
Hello @zulip/server-api members, this issue was labeled with the "area: api", "area: documentation (api and integrations)" labels, so you may want to check it out!

<!-- areaLabelAddition -->
We don't usefully *use* that field, but it looks like we do access it. ... But I think the impact of it going missing would be limited to us sometimes recreating it in our internal data structures, with a value of `undefined`.

Specifically, there's this in `src/message/messagesReducer.js`:
```
  return {
    ...state,
    [action.message_id]: {
      ...oldMessage,
      content: action.rendered_content || oldMessage.content,
      subject: action.subject || oldMessage.subject,
      subject_links: action.subject_links || oldMessage.subject_links,
```

That's in the handler for `update_message` events. We're maintaining the `subject_links` property on our own copy of the message, starting from the value that came straight from the server's JSON for the message.

(The line is pretty bogus in any event -- our type annotations say that the `subject_links` field on both message and event are either `string[]` or `$ReadOnlyArray<string>`, which if true would mean the value is always truthy and the `||` is meaningless.)

So, it *should* work fine. What I'd ask is just:
* When developing this change, please [point the mobile app](https://github.com/zulip/zulip-mobile/blob/master/docs/howto/dev-server.md#summary-checklist) at a dev server with the change, and test that it doesn't break.
  * No mobile dev environment needed; just the published release of the app.
* In particular, test the following sequence:
  * Go look at some message.
  * From another device, edit the message.
  * Check that the edit comes through correctly, and there's no crash or error message.

@zulipbot claim
@zulipbot abandon
@zulipbot claim
Hello @hackerkid, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?

If so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.

If you've decided to work on something else, simply comment `@zulipbot abandon` so that someone else can claim it and continue from where you left off.

Thank you for your valuable contributions to Zulip!

<!-- inactiveWarning -->

Resolving patch:
diff --git a/zerver/lib/topic.py b/zerver/lib/topic.py
--- a/zerver/lib/topic.py
+++ b/zerver/lib/topic.py
@@ -23,7 +23,7 @@
 # Only use these constants for events.
 ORIG_TOPIC = "orig_subject"
 TOPIC_NAME = "subject"
-TOPIC_LINKS = "subject_links"
+TOPIC_LINKS = "topic_links"
 MATCH_TOPIC = "match_subject"
 
 # This constant is actually embedded into


Test patch:
diff --git a/frontend_tests/node_tests/echo.js b/frontend_tests/node_tests/echo.js
--- a/frontend_tests/node_tests/echo.js
+++ b/frontend_tests/node_tests/echo.js
@@ -62,7 +62,7 @@ run_test('process_from_server for differently rendered messages', () => {
             timestamp: old_value,
             is_me_message: old_value,
             submessages: old_value,
-            subject_links: old_value,
+            topic_links: old_value,
         },
     };
     const server_messages = [
@@ -72,7 +72,7 @@ run_test('process_from_server for differently rendered messages', () => {
             timestamp: new_value,
             is_me_message: new_value,
             submessages: new_value,
-            subject_links: new_value,
+            topic_links: new_value,
         },
     ];
     echo._patch_waiting_for_awk(waiting_for_ack);
@@ -86,7 +86,7 @@ run_test('process_from_server for differently rendered messages', () => {
         timestamp: new_value,
         is_me_message: new_value,
         submessages: new_value,
-        subject_links: new_value,
+        topic_links: new_value,
     }]);
 });