add metadata to file upload so it works on the app
This commit is contained in:
parent
16c9fd4148
commit
21a15c5efc
@ -13,7 +13,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"matrix-js-sdk": "^5.0.1",
|
"matrix-js-sdk": "^6.2.1",
|
||||||
"node-localstorage": "^2.1.5",
|
"node-localstorage": "^2.1.5",
|
||||||
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
|
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
|
||||||
"uuidv4": "^6.0.2",
|
"uuidv4": "^6.0.2",
|
||||||
|
17
src/bot.js
17
src/bot.js
@ -116,7 +116,7 @@ class OcrccBot {
|
|||||||
const user = this.client.getUser(memberId);
|
const user = this.client.getUser(memberId);
|
||||||
if (
|
if (
|
||||||
user &&
|
user &&
|
||||||
user.presence === "online" &&
|
(user.presence === "online" || user.presence === "unavailable") &&
|
||||||
memberId !== this.config.BOT_USERID
|
memberId !== this.config.BOT_USERID
|
||||||
) {
|
) {
|
||||||
chatOffline = false;
|
chatOffline = false;
|
||||||
@ -288,17 +288,20 @@ class OcrccBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filename = path.basename(transcriptFile) || "Transcript";
|
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({
|
const url = await this.client.uploadContent(file, { rawResponse: false, type: 'text/plain' })
|
||||||
stream: stream,
|
logger.log('info', url)
|
||||||
name: filename
|
|
||||||
})
|
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
msgtype: "m.file",
|
msgtype: "m.file",
|
||||||
body: filename,
|
body: filename,
|
||||||
url: JSON.parse(contentUrl).content_uri,
|
info: {
|
||||||
|
size: stats.size,
|
||||||
|
mimetype: 'text/plain'
|
||||||
|
},
|
||||||
|
url: url.content_uri,
|
||||||
showToUser: senderId
|
showToUser: senderId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3762,10 +3762,10 @@ map-visit@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
object-visit "^1.0.0"
|
object-visit "^1.0.0"
|
||||||
|
|
||||||
matrix-js-sdk@^5.0.1:
|
matrix-js-sdk@^6.2.1:
|
||||||
version "5.1.0"
|
version "6.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-5.1.0.tgz#9b3b02af227ecc2d0cc35fb7312c92b8a6754293"
|
resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-6.2.1.tgz#d5f76491a650c0a36fcdd078cff59f2da96edd7b"
|
||||||
integrity sha512-IGRq5iACiKp3iIxAghwtdBPrbdgORowc0i8YuIMkZZMpRJDXnNaudt2BFwyQdukV7gvzz7F0sfxBUerySfOnKA==
|
integrity sha512-X12Y2SMg8MOJwE5P3VMsMV/mnQHOmyJkF+FZRida124w4B4tBJouaNxteYyYaH34w+wyaKGxuqEBXecfSpfvbw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.8.3"
|
"@babel/runtime" "^7.8.3"
|
||||||
another-json "^0.2.0"
|
another-json "^0.2.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user