module.exports = {
    friendlyName: 'Unsubscribe from 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: 'unsubscribe' });
        return exits.success({ ok: true });
    }
};


