Skip to content

Modifications in Ghost codebase

Shubham Singh edited this page Aug 11, 2019 · 2 revisions

Ghost(Server-side)

Authentication

Ghost provides authentication using login/password and other Oauth methods using various sites like google, facebook, etc. We required the platform for the Rocket chat users. Therefore we modified the platform authentication methods and provided only a single way to authenticate, i.e., via Rocket chat panel. auth shows the diff of the authentication method for new users, and during setup of Ghost. addUser function will check the id and token and from RC API and after verifying all roles and permissions, populate the user in Ghost. The API callbacks between Ghost and RC, for authentication and setup. Setup User

Populating User

Ghost allows to add user with email-id and sending an invitation email with a token. We modified this workflow and added two ways of adding user in Ghost:

  1. By manually adding RC user by Admin/Owner.
  2. Any RC User can create his/her account from a single click from Sidenavbar header. There is an option for admin to disable the second option, which will restrict any non-Ghost RC user to create his/her account in Ghost.

Roles

Owner- There is only ever one owner of a Ghost site. The owner is a special user which has all the same permissions as an Administrator, The Owner can never be deleted.
Administrator- The top user level in Ghost is Administrator. Again, administrators can do everything that Authors and Editors can do, but they can also edit all site settings. Additionally, administrators have full access to add, manage or remove any other user of the site.
Editor- Editors are the 3rd user level in Ghost. Editors can do everything that an Author can do. Editors can also invite new Contributors to the site.
Author- Authors are the 2nd user level in Ghost. Authors can write, edit and publish their own posts. Authors are trusted users. If you don't trust users to be allowed to publish their own posts, they should be set as Contributors.
Contributor- This is the base user level in Ghost. Contributors can create and edit their own draft posts, but they are unable to publish posts. All the draft posts created by Contributors will have its parent user as Author. (Parent user is one who has added the contributor).
Contributors have a parent user, which is the one who added it. Author can not own any Contributor users; only Editor and above user role can have their own contributors.

Models

Diff: Schema for fields

User

The following fields are deleted from User Table in DB.

  • name
  • email
  • password
  • profile_image The following fields are added to User Table in DB.
  • rc_id RC user Id. The deleted fields will be fetched everytime from MongoDB.

Post

The following fields are added to User Table in DB.

  • room_id: stores the roomId where the post is announced and also the room where user want to collaborate with room members.
  • discussion_room_id: stores the discussion roomId for comments in Post.
  • announce: Boolean value to announce the post during publish of post.
  • collaborate: Boolean value to collaborate on post with members of room_id.
  • is_private: Boolean value to restrict the post view page to the members of announcing post only.
  • rc_image: Image link to customize the announcing message.
  • rc_title: Customized title for announcing message.
  • rc_description: Customized description for announcing message.

Parent User

Parent User Table is added to Specify the relation between User and its Parent User. Useful in case of the contributor user where the relation between user and its parent editor is defined under this table. Fields:

  • parent_id: id of parent editor.
  • user_id: id of contributor user.

Invite Table is deleted from the db which was used to store the invite token to populate users in Ghost. As we don't want to add the user by e-mail we don't required this method.

Db-Utils

New file. This file is responsible for fetching all the RC related details from MongoDB which are not stored in GhostDB to avoid data sync issue. It will be used everytime the model layer of Ghost is used to fetch user/post details.

Comments

Comment room is a discussion room with parent room as the direct room between user with himself/herself. This room is used to allow user to have full owner-ship of the discussion room of his/her post. The discussion room is allowed to be created in private as well as public mode. This endpoint will be used from Ghost front-side to create discussion room whenever a post is published.

Ghost-Admin(Frontend)

Invite User

This modal is used to invite new user from RC to Ghost. Only Owner/Admin can access this modal. modal

Edit/Create Post

Some post settings added which will allow the user set announcement room name and toggle settings for announcement/collaborate/private post/private discussion.
post-setting

User

User detail to edit user details(settings which are imported from RC are read-only).
user

Settings

Setting Page for RC related settings.
setting

Ghost-Cli

NPM package for rc-ghost-cli which is modification version of ghost-cli. It fetched ghost and install ghost on your server. Instructions to use ghost-cli, replace ghost_cli with rc-ghost-cli. Instructions to install ghost locally in dev mode using npm package.