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:
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user