Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Get.js « Setting « Controller « js « src - github.com/marius-wieschollek/passwords-webextension.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8c29300cfdedcb1591d7f707e655ea3372d6826d (plain)
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
54
55
import AbstractController from '@js/Controller/AbstractController';
import SettingsService from '@js/Services/SettingsService';

export default class Get extends AbstractController {

    constructor() {
        super();
        this._readableSettings = [
            'password.autosubmit',
            'password.generator.strength',
            'password.generator.numbers',
            'password.generator.special',
            'popup.autoclose',
            'popup.related.search',
            'notification.password.new',
            'notification.password.update',
            'server.default',
            'theme.current',
            'theme.custom',
            'debug.localisation.enabled'
        ];
    }

    /**
     *
     * @param {Message} message
     * @param {Message} reply
     * @return {Promise<void>}
     */
    async execute(message, reply) {
        let setting = message.getPayload();

        try {
            if(this._readableSettings.indexOf(setting) !== -1) {
                /** @type {Setting} **/
                let model = await SettingsService.get(setting);
                reply.setType('setting.value').setPayload({value:model.getValue(), scope:model.getScope()});
            } else {
                reply.setPayload(
                    {
                        success: false,
                        message: 'Unknown setting'
                    }
                );
            }
        } catch(e) {
            reply.setPayload(
                {
                    success: false,
                    message: e.message
                }
            );
        }
    }
}