UNPKG

@anjir/app-novinhub

Version:

نوین هاب - پلتفرم کامل مدیریت شبکه‌های اجتماعی، دایرکت هوشمند، و خودکارسازی پیام‌رسانی

68 lines 2.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.novinhubReactToMessageAction = void 0; const apps_framework_1 = require("@anjir/apps-framework"); const apps_common_1 = require("@anjir/apps-common"); const index_1 = require("../../index"); const common_1 = require("../common"); exports.novinhubReactToMessageAction = (0, apps_framework_1.createAction)({ auth: index_1.novinhubAuth, name: 'react_to_message', displayName: 'واکنش به پیام', description: 'اضافه یا حذف واکنش به یک پیام', props: { messageId: apps_framework_1.Property.Number({ displayName: 'شناسه پیام', description: 'شناسه پیامی که می‌خواهید واکنش نشان دهید', required: true, }), type: apps_framework_1.Property.StaticDropdown({ displayName: 'نوع واکنش', description: 'نوع واکنش (در حال حاضر فقط like پشتیبانی می‌شود)', required: true, options: { disabled: false, options: [ { label: 'لایک', value: 'like' }, ], }, }), }, async run(ctx) { const { messageId, type } = ctx.propsValue; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${ctx.auth.access_token}`, }; const body = { type, }; const url = (0, common_1.buildApiUrl)(`/conversation/message/${messageId}/reaction`); try { const response = await apps_common_1.httpClient.sendRequest({ method: apps_common_1.HttpMethod.PUT, url: url, headers: headers, body: body, }); if (response.status === 200) { return { success: true, result: response.body, message: 'واکنش با موفقیت ثبت شد', }; } else { throw new Error(`خطا در ثبت واکنش: ${response.body?.message || `HTTP ${response.status}`}`); } } catch (error) { const errorMessage = error.message || error.toString() || 'خطا در ثبت واکنش'; return { success: false, error: errorMessage, }; } }, }); //# sourceMappingURL=react-to-message.js.map