index.ts 947 Bytes
Newer Older
1
const { handleChanges } = require('./server/settings');
2
3

async function register({
4
  registerSetting,
5
  registerHook,
6
7
  settingsManager,
  videoCategoryManager,
8
  peertubeHelpers,
lutangar's avatar
wip    
lutangar committed
9
}: RegisterServerOptions) {
10
  const { logger } = peertubeHelpers;
11

12
13
14
15
16
17
18
19
20
21
  registerHook({
    target: 'action:application.listening',
    handler: async () => {
      handleChanges({
        videoCategoryManager,
        logger,
      })(await settingsManager.getSettings(['json-categories-as-text']));
    },
  });

22
  registerSetting({
23
24
25
26
27
28
29
30
    name: 'json-categories-as-text',
    label: 'settings.json_categories.label',
    type: 'input-textarea',
    default: JSON.stringify({ add: [], delete: [] }),
    descriptionHTML: 'settings.json_categories.description',
  });

  settingsManager.onSettingsChange(
31
    handleChanges({
32
33
      videoCategoryManager,
      logger,
34
    })
35
  );
36
37
}

38
39
async function unregister() {
  return;
40
41
42
43
}

module.exports = {
  register,
44
45
  unregister,
};