UNPKG

@anjir/app-novinhub

Version:

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

53 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.novinhubLikeCommentAction = 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.novinhubLikeCommentAction = (0, apps_framework_1.createAction)({ auth: index_1.novinhubAuth, name: 'like_comment', displayName: 'لایک کامنت', description: 'لایک یا حذف لایک یک کامنت', props: { commentId: apps_framework_1.Property.Number({ displayName: 'شناسه کامنت', description: 'شناسه کامنتی که می‌خواهید لایک کنید', required: true, }), }, async run(ctx) { const { commentId } = ctx.propsValue; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${ctx.auth.access_token}`, }; const url = (0, common_1.buildApiUrl)(`/comment/${commentId}/like`); try { const response = await apps_common_1.httpClient.sendRequest({ method: apps_common_1.HttpMethod.PUT, url: url, headers: headers, }); 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=like-comment.js.map