generated from NodeBB/nodebb-plugin-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.js
53 lines (42 loc) · 1.34 KB
/
library.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
const nconf = require.main.require('nconf');
const winston = require.main.require('winston');
const controllers = require('./lib/controllers');
const settings = require.main.require("./src/meta/settings")
const routeHelpers = require.main.require('./src/routes/helpers');
const plugin = {};
let settingData = {};
plugin.init = async (params) => {
const {
router,
middleware/* , controllers */
} = params;
/**
* We create two routes for every view. One API call, and the actual route itself.
* Use the `setupPageRoute` helper and NodeBB will take care of everything for you.
*
* Other helpers include `setupAdminPageRoute` and `setupAPIRoute`
* */
settingData = await settings.get("avatar-replace");
//console.log(settingData);
routeHelpers.setupAdminPageRoute(router, '/admin/plugins/avatar-replace-admin', middleware, [], controllers.renderAdminPage);
};
plugin.addAdminNavigation = (header) => {
header.plugins.push({
route: '/plugins/avatar-replace-admin',
icon: 'fa-tint',
name: 'AvatarReplace',
});
return header;
};
plugin.userGetFields = async (data) => {
if (settingData["replace-switch"] === "on"){
data.users.forEach((obj) =>{
if (obj.picture && !obj.picture.startsWith("/assets")){
obj.picture = ""
}
})
}
return data;
};
module.exports = plugin;