module.exports = {
    friendlyName: 'Subscribe to FCM topic',

    inputs: {
        fcmToken: { type: 'string', required: true },
        topic: { type: 'string', required: true }
    },

    exits: {
        success: { responseType: 'ok' },
        badRequest: { responseType: 'badRequest' }
    },

    fn: async function (inputs, exits) {
        if (!inputs.topic || !inputs.fcmToken) {
            return exits.badRequest({ message: 'Paramètres manquants' });
        }
        await sails.helpers.manageFcmTopic.with({ fcmToken: inputs.fcmToken, topic: inputs.topic, action: 'subscribe' });
        return exits.success({ ok: true });
    }
};


