From d05672a2dcef986e2bff550c7f704610b31d529d Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 22 Oct 2020 00:53:13 +0300 Subject: [PATCH] Expose the display roles module to plugins --- CHANGELOG.md | 2 ++ src/data/Thread.js | 2 +- src/data/{moderatorRoleOverrides.js => displayRoles.js} | 0 src/modules/roles.js | 2 +- src/pluginApi.js | 2 ++ src/plugins.js | 2 ++ 6 files changed, 8 insertions(+), 2 deletions(-) rename src/data/{moderatorRoleOverrides.js => displayRoles.js} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b83d333..e2d95cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ Please report any bugs you encounter by [creating a GitHub issue](https://github * System messages now have a formatter * The `beforeNewThread` hook's parameters now also include the original DM message object * Plugins can now access the `threads` module (via `pluginApi.threads`) to create and fetch threads +* Plugins can now access the `displayRoles` module (via `pluginApi.displayRoles`) to get, set, and reset display role overrides for moderators, + and to get the final role that will be displayed in moderator replies (by default or per-thread) **Internal/technical updates:** * Modmail now uses [Express](https://expressjs.com/) as its web server for logs/attachments diff --git a/src/data/Thread.js b/src/data/Thread.js index 27f9a0e..09c75dc 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -9,7 +9,7 @@ const attachments = require("./attachments"); const { formatters } = require("../formatters"); const { callAfterThreadCloseHooks } = require("../hooks/afterThreadClose"); const snippets = require("./snippets"); -const { getModeratorThreadDisplayRoleName } = require("./moderatorRoleOverrides"); +const { getModeratorThreadDisplayRoleName } = require("./displayRoles"); const ThreadMessage = require("./ThreadMessage"); diff --git a/src/data/moderatorRoleOverrides.js b/src/data/displayRoles.js similarity index 100% rename from src/data/moderatorRoleOverrides.js rename to src/data/displayRoles.js diff --git a/src/modules/roles.js b/src/modules/roles.js index 5ba59a8..9b77744 100644 --- a/src/modules/roles.js +++ b/src/modules/roles.js @@ -8,7 +8,7 @@ const { getModeratorThreadDisplayRoleName, getModeratorDefaultDisplayRoleName, -} = require("../data/moderatorRoleOverrides"); +} = require("../data/displayRoles"); const ROLE_OVERRIDES_METADATA_KEY = "moderatorRoleOverrides"; diff --git a/src/pluginApi.js b/src/pluginApi.js index 4fdcac9..8ea5fc7 100644 --- a/src/pluginApi.js +++ b/src/pluginApi.js @@ -3,6 +3,7 @@ const { CommandManager } = require("knub-command-manager"); const { Client } = require("eris"); const Knex = require("knex"); const threads = require("./data/threads"); +const displayRoles = require("./data/displayRoles"); /** * @typedef {object} PluginAPI @@ -16,6 +17,7 @@ const threads = require("./data/threads"); * @property {FormattersExport} formats * @property {express.Application} webserver * @property {threads} threads + * @property {displayRoles} displayRoles */ /** diff --git a/src/plugins.js b/src/plugins.js index c0741fe..894c529 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -8,6 +8,7 @@ const childProcess = require("child_process"); const pacote = require("pacote"); const path = require("path"); const threads = require("./data/threads"); +const displayRoles = require("./data/displayRoles"); const pluginSources = { npm: { @@ -130,6 +131,7 @@ module.exports = { formats, webserver, threads, + displayRoles, }; }, };