Skip to content

Instantly share code, notes, and snippets.

@fliptrail
Last active August 23, 2021 20:46
Show Gist options
  • Save fliptrail/d2f2068cf7604aa7e7e17947b5892c26 to your computer and use it in GitHub Desktop.
Save fliptrail/d2f2068cf7604aa7e7e17947b5892c26 to your computer and use it in GitHub Desktop.
My GSoC Work submission and summary for Rocket.Chat in 2019

GSoC logo Rocket.Chat logo

Google Summer of Code 2019

Project: Implementation of Newsfeed (a social feature) in Rocket.Chat Server

by Amish Mittal

About Me

Namaste! I am Amish Mittal, a sophomore (was a freshman when started GSoC) BTech Computer Science student at Indian Institute of Technology Patna (IIT Patna). Feel free to contact me on any of the contact information mentioned below.

Contact:

Special thanks to my Mentors and community:

  • Peter Lepeska
  • Karan Bedi
  • Devin Toth
  • Eric Rosenthal
  • Jay Hepburn

Mentor Feedback:

Eval 1 Eval 2 Eval 3

Mid-point review:

Mid-term presentation: https://slides.com/amishmittal/newsfeed/

Mid term video demo: https://drive.google.com/open?id=1-mU9Rp3oTJQ3s8e06haIWy0Qx5eay-1o

Aim

The aim of this project is to add a newsfeed for every user. In it, the users can follow other users. Whenever a user posts something in a public channel or does any public activity, it would appear in the newsfeed of all his followers with a link to the original post in the original channel. This would greatly help in discovering new conversations, increasing accountability of people in the organisation & increasing many folds the time a user spends on RC

The most challenging part of creating the newsfeed is to make it scalable to support a large number of concurrent users (by using an adaptive follower/following relation model) and to benchmark the server performance in relaying the correct messages with filters. This is being done by using proper schema and proper database queries. Messages in newsfeed are fetched in real-time from messages stored for other channels. This also includes their summarization and selection in real-time to prevent spam in the newsfeed.

Link to pull requests highlighting seperate changes

Note: These are pull requests made in succession. The PRs below contain changes of the previous PRs too. The changes in one PR maybe modified heavily in the next PR.
  • Admin setting to enable/disable newsfeed (Default is false to prevent conflicts under work is correct)
  • Newsfeed schema of channel type 'n'
  • Newsfeed for every new user
  • Newsfeed creation with userId
  • Adding of Follow user/ unfollow user methods (changed later)
  • Added getFollowers and hasAlreadyFollowed method (changed later)
  • UI changes for follow/unfollow button
  • Object type schema to store followers and following (changed later)
  • Changed newsfeed to private type channel
  • Creation of new direct queries to extract correct messages (modified later)
  • Security bug for private messages fixed later
  • Creation of loadNewsfeedHistory and following functions in Message.js
  • Displaying of newsfeed messages on client side by retrieving them from miniMongo
  • Addition of original channel name in front of sender name in newsfeed
  • Change in sequencing of messages in newsfeed
  • Bug fixes in next PR
  • Updation of follower schema, now based upon Subscription model
  • User Relations collection
  • Lightweight and scalable
  • canAccessRoom function used for correct permissions
  • Displaying of newsfeed messages on client side by retrieving them from miniMongo
  • Migration of all previous methods to new schema
  • Time and channel based summarization model
  • Bug fixes
  • Summarization on the client side
  • using list of Accessible rooms
  • Add jump button in message header
  • Clicking on it leads the user to original channel
  • Work in progress
  • Add number of followers and following in user info tab
  • Work in progress for displaying the list for a large number of followers

Final Pull Request containing all commits: RocketChat/Rocket.Chat#23010 or fliptrail/Rocket.Chat#7

Current Bugs:

  1. The original channel ID is displayed instead of original channel name (identified)
  2. Sometimes reload is required for newsfeed to update (not-identified)
  3. Display list of followers does not work for large number of followers (not-identified)
  4. Clicking on Jump redirects to original channel only (identified)
  5. Possible empty $or/$and selector in hasAlreadyFollowed method

Performance Considerations:

Message summarization is a bit heavy and it is being done twice currently - on both server and client. User Relations collection is lightweight and based upon the current User Subscription model.

Further steps:

  1. Fixing of bugs listed above.
  2. Major UI changes in accordance with Design team suggestions
  3. Filtering and grouping of messages in newsfeed according to date/original channel/original sender
  4. UI for "embedded conversations"
  5. Security test to make sure that messages from private groups/channels are not relayed.

Link to my fork of Rocket.Chat: https://github.com/fliptrail/Rocket.Chat

Corresponding branches can be seen according to the Pull Requests made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment