};
const handleSendSticker = async (data) => {
- const { mxc: url, body, httpUrl } = data;
- const info = {};
-
- const img = new Image();
- img.src = httpUrl;
-
- try {
- const res = await fetch(httpUrl);
- const blob = await res.blob();
- info.w = img.width;
- info.h = img.height;
- info.mimetype = blob.type;
- info.size = blob.size;
- info.thumbnail_info = { ...info };
- info.thumbnail_url = url;
- } catch {
- // send sticker without info
- }
-
- mx.sendEvent(roomId, 'm.sticker', {
- body,
- url,
- info,
- });
+ roomsInput.sendSticker(roomId, data);
};
function processTyping(msg) {
import { encode } from 'blurhash';
import { getShortcodeToEmoji } from '../../app/organisms/emoji-board/custom-emoji';
import { mathExtensionHtml, spoilerExtension, spoilerExtensionHtml } from '../../util/markdown';
-import { getImageDimension } from '../../util/common';
import cons from './cons';
import settings from './settings';
this.emit(cons.events.roomsInput.MESSAGE_SENT, roomId);
}
+ async sendSticker(roomId, data) {
+ const { mxc: url, body, httpUrl } = data;
+ const info = {};
+
+ const img = new Image();
+ img.src = httpUrl;
+
+ try {
+ const res = await fetch(httpUrl);
+ const blob = await res.blob();
+ info.w = img.width;
+ info.h = img.height;
+ info.mimetype = blob.type;
+ info.size = blob.size;
+ info.thumbnail_info = { ...info };
+ info.thumbnail_url = url;
+ } catch {
+ // send sticker without info
+ }
+
+ this.matrixClient.sendEvent(roomId, 'm.sticker', {
+ body,
+ url,
+ info,
+ });
+ this.emit(cons.events.roomsInput.MESSAGE_SENT, roomId);
+ }
+
async sendFile(roomId, file) {
const fileType = file.type.slice(0, file.type.indexOf('/'));
const info = {