UNPKG

3.23 kBJavaScriptView Raw
1/*
2Copyright 2018 New Vector Ltd
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16"use strict";
17
18/** @module ContentHelpers */
19
20module.exports = {
21 /**
22 * Generates the content for a HTML Message event
23 * @param {string} body the plaintext body of the message
24 * @param {string} htmlBody the HTML representation of the message
25 * @returns {{msgtype: string, format: string, body: string, formatted_body: string}}
26 */
27 makeHtmlMessage: function makeHtmlMessage(body, htmlBody) {
28 return {
29 msgtype: "m.text",
30 format: "org.matrix.custom.html",
31 body: body,
32 formatted_body: htmlBody
33 };
34 },
35
36 /**
37 * Generates the content for a HTML Notice event
38 * @param {string} body the plaintext body of the notice
39 * @param {string} htmlBody the HTML representation of the notice
40 * @returns {{msgtype: string, format: string, body: string, formatted_body: string}}
41 */
42 makeHtmlNotice: function makeHtmlNotice(body, htmlBody) {
43 return {
44 msgtype: "m.notice",
45 format: "org.matrix.custom.html",
46 body: body,
47 formatted_body: htmlBody
48 };
49 },
50
51 /**
52 * Generates the content for a HTML Emote event
53 * @param {string} body the plaintext body of the emote
54 * @param {string} htmlBody the HTML representation of the emote
55 * @returns {{msgtype: string, format: string, body: string, formatted_body: string}}
56 */
57 makeHtmlEmote: function makeHtmlEmote(body, htmlBody) {
58 return {
59 msgtype: "m.emote",
60 format: "org.matrix.custom.html",
61 body: body,
62 formatted_body: htmlBody
63 };
64 },
65
66 /**
67 * Generates the content for a Plaintext Message event
68 * @param {string} body the plaintext body of the emote
69 * @returns {{msgtype: string, body: string}}
70 */
71 makeTextMessage: function makeTextMessage(body) {
72 return {
73 msgtype: "m.text",
74 body: body
75 };
76 },
77
78 /**
79 * Generates the content for a Plaintext Notice event
80 * @param {string} body the plaintext body of the notice
81 * @returns {{msgtype: string, body: string}}
82 */
83 makeNotice: function makeNotice(body) {
84 return {
85 msgtype: "m.notice",
86 body: body
87 };
88 },
89
90 /**
91 * Generates the content for a Plaintext Emote event
92 * @param {string} body the plaintext body of the emote
93 * @returns {{msgtype: string, body: string}}
94 */
95 makeEmoteMessage: function makeEmoteMessage(body) {
96 return {
97 msgtype: "m.emote",
98 body: body
99 };
100 }
101};
102//# sourceMappingURL=content-helpers.js.map
\No newline at end of file