Add pinThreadHeader option

cshd
Dragory 2020-11-01 23:26:38 +02:00
parent a5279feb18
commit 7a9bcc5b95
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
5 changed files with 21 additions and 2 deletions

View File

@ -278,6 +278,10 @@ If enabled, a system message will be posted into any open threads if the user le
**Default:** `on` **Default:** `on`
If enabled, the bot will mention staff (see `mentionRole` option) on the inbox server when the bot is mentioned on the main server. If enabled, the bot will mention staff (see `mentionRole` option) on the inbox server when the bot is mentioned on the main server.
#### pinThreadHeader
**Default:** `off`
If enabled, the bot will pin the "thread header" message in each thread that contains the user's details
#### plugins #### plugins
**Default:** *None* **Default:** *None*
**Accepts multiple values.** External plugins to load on startup. See [Plugins](plugins.md) for more information. **Accepts multiple values.** External plugins to load on startup. See [Plugins](plugins.md) for more information.

View File

@ -464,7 +464,12 @@ class Thread {
const msg = await this._postToThreadChannel(finalContent); const msg = await this._postToThreadChannel(finalContent);
threadMessage.inbox_message_id = msg.id; threadMessage.inbox_message_id = msg.id;
await this._addThreadMessageToDB(threadMessage.getSQLProps()); const finalThreadMessage = await this._addThreadMessageToDB(threadMessage.getSQLProps());
return {
message: msg,
threadMessage: finalThreadMessage,
};
} }
/** /**

View File

@ -64,6 +64,7 @@
* @property {string} [fallbackRoleName=null] * @property {string} [fallbackRoleName=null]
* @property {boolean} [autoAlert=false] * @property {boolean} [autoAlert=false]
* @property {string} [autoAlertDelay="2m"] Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds. * @property {string} [autoAlertDelay="2m"] Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds.
* @property {boolean} [pinThreadHeader=false]
* @property {string} [logStorage="local"] * @property {string} [logStorage="local"]
* @property {object} [logOptions] * @property {object} [logOptions]
* @property {string} logOptions.attachmentDirectory * @property {string} logOptions.attachmentDirectory

View File

@ -357,6 +357,11 @@
"description": "Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds." "description": "Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds."
}, },
"pinThreadHeader": {
"$ref": "#/definitions/customBoolean",
"default": false
},
"logStorage": { "logStorage": {
"type": "string", "type": "string",
"default": "local" "default": "local"

View File

@ -287,10 +287,14 @@ async function createNewThreadForUser(user, opts = {}) {
infoHeader += "\n────────────────"; infoHeader += "\n────────────────";
await newThread.postSystemMessage(infoHeader, { const { message: threadHeaderMessage } = await newThread.postSystemMessage(infoHeader, {
allowedMentions: config.mentionUserInThreadHeader ? { users: [user.id] } : undefined, allowedMentions: config.mentionUserInThreadHeader ? { users: [user.id] } : undefined,
}); });
if (config.pinThreadHeader) {
await threadHeaderMessage.pin();
}
if (config.updateNotifications) { if (config.updateNotifications) {
const availableUpdate = await updates.getAvailableUpdate(); const availableUpdate = await updates.getAvailableUpdate();
if (availableUpdate) { if (availableUpdate) {