Class ChattingController


  • @RestController
    @RequestMapping("/chat-api")
    @CrossOrigin("http://localhost:3000")
    public class ChattingController
    extends Object
    This controller defines end-points that are necessary to support chat related services
    Author:
    mayankkakad
    • Constructor Detail

      • ChattingController

        public ChattingController()
    • Method Detail

      • sendMessage

        @PostMapping("/sendMessage")
        public void sendMessage​(@RequestHeader("authorization")
                                String authorizationToken,
                                @RequestBody
                                Map<String,​Object> message)
                         throws AuthorizationFailedException,
                                AuthenticationFailedException
        An API call which check's the validity of the user and uploads message on the firebase as well as on SQLite database
        Parameters:
        authorizationToken - The firebase token/JWT which identifies the user
        message - A map which contains the sender, receiver and the text message
        Throws:
        AuthorizationFailedException - Thrown when the JWT doesn't represent the passed in user id
        AuthenticationFailedException - Thrown when the JWT is invalid
      • getNewMessages

        @GetMapping("/refreshMessages")
        public Vector<MyMessage> getNewMessages​(@RequestHeader("authorization")
                                                String authorizationToken,
                                                @RequestBody
                                                Map<String,​Object> map)
                                         throws AuthorizationFailedException,
                                                AuthenticationFailedException
        An API call which sends any new messages received from any user from the firebase realtime database
        Parameters:
        authorizationToken - The firebase token/JWT which identifies the user
        map - A map which just contains the name of the receiver for which the messages have to be fetched
        Returns:
        A vector of all newly received messages
        Throws:
        AuthorizationFailedException - Thrown when the JWT doesn't represent the passed in user id
        AuthenticationFailedException - Thrown when the JWT is invalid
      • getAllMessages

        @PostMapping("/getMessages")
        public Vector<MyMessage> getAllMessages​(@RequestHeader("authorization")
                                                String authorizationToken,
                                                @RequestBody
                                                Map<String,​Object> map)
                                         throws AuthorizationFailedException,
                                                AuthenticationFailedException
        An API call which sends all the messages of a given user from the SQLite Database (Usually called at application startup)
        Parameters:
        authorizationToken - The firebase token/JWT which identifies the user
        map - A map which just contains the name of the receiver for which the messages have to be fetched
        Returns:
        A vector of all the messages of a particular user
        Throws:
        AuthorizationFailedException - Thrown when the JWT doesn't represent the passed in user id
        AuthenticationFailedException - Thrown when the JWT is invalid
      • deleteMessage

        @PostMapping("/deleteMessage")
        public void deleteMessage​(@RequestHeader("authorization")
                                  String authorizationToken,
                                  @RequestBody
                                  Vector<Map<String,​Object>> messages)
        An API call which deletes the given messages from the SQLite database
        Parameters:
        authorizationToken - The firebase token/JWT which identifies the user
        messages - Vector of messages that have to be deleted