1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-21 00:55:17 +00:00

Can send text messages

This commit is contained in:
2019-11-30 17:13:36 +01:00
parent e377d29096
commit fef321f0ff
5 changed files with 97 additions and 5 deletions

View File

@ -202,6 +202,29 @@ export class ConversationsController {
h.send(h.send(messages.map(e => this.ConversationMessageToAPI(e))));
}
/**
* Send a new message
*
* @param h Request handler
*/
public static async SendMessage(h: RequestHandler) {
const convID = await this.GetPostConversationId("conversationID", h);
const message = removeHTMLNodes(h.postString("message", 0));
if(message.length < 3)
h.error(401, "Message is empty!");
// Send message
await ConversationsHelper.SendMessage({
userID: h.getUserId(),
convID: convID,
message: message,
imagePath: ""
});
h.success("Conversation message was sent!");
}
/**
* Get and return safely a conversation ID specified in a $_POST Request
*

View File

@ -60,6 +60,8 @@ export const Routes : Route[] = [
{path: "/conversations/refresh", cb: (h) => ConversationsController.RefreshList(h)},
{path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)},
{path: "/conversations/sendMessage", cb: (h) => ConversationsController.SendMessage(h)},
// Search controller