add metadata to file upload so it works on the app
This commit is contained in:
17
src/bot.js
17
src/bot.js
@@ -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
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user