Class ChattingController
- java.lang.Object
-
- in.cs699.tensors.delagram.chatting_service.controller.ChattingController
-
@RestController @RequestMapping("/chat-api") @CrossOrigin("http://localhost:3000") public class ChattingController extends ObjectThis controller defines end-points that are necessary to support chat related services- Author:
- mayankkakad
-
-
Constructor Summary
Constructors Constructor Description ChattingController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteMessage(String authorizationToken, Vector<Map<String,Object>> messages)An API call which deletes the given messages from the SQLite databaseVector<MyMessage>getAllMessages(String authorizationToken, Map<String,Object> map)An API call which sends all the messages of a given user from the SQLite Database (Usually called at application startup)Vector<MyMessage>getNewMessages(String authorizationToken, Map<String,Object> map)An API call which sends any new messages received from any user from the firebase realtime databasevoidsendMessage(String authorizationToken, Map<String,Object> message)An API call which check's the validity of the user and uploads message on the firebase as well as on SQLite database
-
-
-
Method Detail
-
sendMessage
@PostMapping("/sendMessage") public void sendMessage(@RequestHeader("authorization") String authorizationToken, @RequestBody Map<String,Object> message) throws AuthorizationFailedException, AuthenticationFailedExceptionAn 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 usermessage- A map which contains the sender, receiver and the text message- Throws:
AuthorizationFailedException- Thrown when the JWT doesn't represent the passed in user idAuthenticationFailedException- Thrown when the JWT is invalid
-
getNewMessages
@GetMapping("/refreshMessages") public Vector<MyMessage> getNewMessages(@RequestHeader("authorization") String authorizationToken, @RequestBody Map<String,Object> map) throws AuthorizationFailedException, AuthenticationFailedExceptionAn 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 usermap- 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 idAuthenticationFailedException- Thrown when the JWT is invalid
-
getAllMessages
@PostMapping("/getMessages") public Vector<MyMessage> getAllMessages(@RequestHeader("authorization") String authorizationToken, @RequestBody Map<String,Object> map) throws AuthorizationFailedException, AuthenticationFailedExceptionAn 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 usermap- 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 idAuthenticationFailedException- 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 usermessages- Vector of messages that have to be deleted
-
-