Skip to content

1. Welcome

TecOrb Technologies edited this page Oct 5, 2022 · 1 revision

Welcome to the rails-chat-action-cable wiki!

Action cable live chat module APIs rails application

In this project we have implemented apis to manage authentication and live chatting module using Action cable. Below are the APIs list (Module-wise)

1. Auth module

  • User Registration
  • User Login
  • Manage Access Token via Refresh Token
  • Logout

2. Chat module

  • Conversations list
  • Remove Conversations (Single and bulk)
  • Send message (To specific conversation)
  • Remove messages in bulk (From loggedin user's list only, receipients will see the messages)
  • Delete Messages (From me ony and from all receipients as well)
  • Messages List (From a specific Conversation)
  • Mark Messages as seen/unseen (Bulk and single)
  • Message delivery/seen/unseen tracking (Bulk and single)

Info for client app developers (iOS, Android, Web) to integrate these APIs

You would need to use Action cable SDK for your domain.

Action Cable Response Codes are used to handle on client apps (might be iOS/Android/Web)

We are managing Action Cable notifications by their codes. Here are the codes to handle the received notifications on client applications.

  • 10: New Message
  • 11: Remove Message
  • 12: Seen Message
  • 14: Delivered Message

When any activity happen with respect to a message or a new message over the server, client will be notify by these code in Action Cable broadcast on their subscribed channel.

Postman collection is attached here

We have documented all of these APIs using postman collections with their responses as well. Please download and import this in your postman to get direct endpoints access to the APIs with required body, headers etc.

Here is the postman collection link https://github.com/TecOrb-Developers/rails-chat-action-cable/blob/main/documentation/Chat-Module.postman_collection.json

Technical assets and dependencies

User authentication is managed via doorkeeper JWT (JSON Web Token)

Doorkeeper JWT adds JWT token support to the Doorkeeper OAuth library. Complete document for integration is here https://github.com/TecOrb-Developers/rails-doorkeeper-auth

Required dependencies:

  • Node (v 16)
  • Yarn (v 1.22.19)
  • Ruby (v 3.0.1)
  • Rails (v 6.1.4)
  • MySQL (v 8.0.29)
  • Git (v 2.32.1)
  • Redis (v >= 4.2.0)
  • Sidekiq (v 6.4.2)
  • Action cable (v 6.1.4.1)
  • Docker (Optional in case running without containers)

Major steps are followed to create this project.

  • Prepared with above dependencies
  • Created a new Rails app
  • Database configuration setup (using MySQL)
  • Initialize a local repository using git
  • .gitignore file created to add configuration.yml
  • configuration.yml file created to initialize environment variables
  • Create a new remote repository using GitHub
  • Change README.md and documentation added
  • Code Commited and Pushed to GitHub repository

About action cable channel

User need to subscribe a chat channel to get notify through action cable. Action Cable url will be send by server where the application is hosted followed by the /cable path. Channel name is initiated by a prefix 'notify_' and user's id.

To subscribe a channel user need to send their access token in 'session_token' key at the time of subscription request. Once user will be authenticated successfully, server will allow to subscribe the requested channel for the client.