emillind / zulip

Zulip server - powerful open source team chat
https://zulip.org/
Other
0 stars 1 forks source link

Have GET /messages serve up topic in the response JSON #7

Closed emillind closed 6 years ago

emillind commented 6 years ago

When fetching messages from the backend those objects serve up topic as a copy of subject.

Part of #6

Aweponken commented 6 years ago

Trying to understand the function. I believe that this codes serves a list of messages based on IDs? And msg_dict["subject"] is already written in the messages, so we're just extending the dictionary with topic?

Aweponken commented 6 years ago

@emillind Is this the only place where messages are fetched from the backend? EDIT: Realised that this question might not be that easy to answer... But maybe this is a good first step. We'll see if stuff gets broken when we change the frontend

joakimboman commented 6 years ago

@Aweponken yes as I understand it you are correct, we're just extending the dictionary with topic which is set to the subject (which is already in there)

eywoon commented 6 years ago

So it doesn't overwrite subject?

emillind commented 6 years ago

There is another endpoint for fetching a specific message but as far as i can see that is only done in the case of trying to edit a message and perhaps for notifications and quotations (you can find this by doing a project search for /messages/ and see which files) as well as different tests. However this version of getting messages only returns the content of the message and not stuff like subject etc.

However what the function i edited does is to

  1. Retrieve all messages in the DB in the form of Dictionaries which is basically JSON objects
  2. Loops over the messages and retrieves the ones we want. It does some other irrelevant stuff
  3. (what i added) Adds a new field to the Dictionary (msg_dict.topic = msg_dict.subject)
  4. Some processing of the dicts
  5. Returns the dicts we wanted.

If you add a console.log(data.messages) in the success-function on line 98 in static/js/message_fetch.js you can see what it returns in action if you browse messages in your local dev server

@Aweponken @jockeboman @eywoon

joakimboman commented 6 years ago

I get this: commit_messages| Commit 9fa5f0b022: commit_messages| 1: Z2 Title does not match regex (^(.+:\ )?[A-Z].+.$): "Have GET /messages serve up topic in the response JSON"

When I run: ./tools/lint --backend

There seems to be a regex that does not want the "/" in the commit message @emillind

emillind commented 6 years ago

Fixed @jockeboman @Aweponken didnt realise you had to follow a regexp