add metadata to file upload so it works on the app

This commit is contained in:
Sharon Kennedy
2020-06-11 01:54:36 -04:00
parent 16c9fd4148
commit 21a15c5efc
3 changed files with 15 additions and 12 deletions

View File

@@ -116,7 +116,7 @@ class OcrccBot {
const user = this.client.getUser(memberId);
if (
user &&
user.presence === "online" &&
(user.presence === "online" || user.presence === "unavailable") &&
memberId !== this.config.BOT_USERID
) {
chatOffline = false;
@@ -288,17 +288,20 @@ class OcrccBot {
}
const filename = path.basename(transcriptFile) || "Transcript";
const stream = fs.createReadStream(transcriptFile);
const file = fs.readFileSync(transcriptFile);
const stats = fs.statSync(transcriptFile);
const contentUrl = await this.client.uploadContent({
stream: stream,
name: filename
})
const url = await this.client.uploadContent(file, { rawResponse: false, type: 'text/plain' })
logger.log('info', url)
const content = {
msgtype: "m.file",
body: filename,
url: JSON.parse(contentUrl).content_uri,
info: {
size: stats.size,
mimetype: 'text/plain'
},
url: url.content_uri,
showToUser: senderId
};