@anjir/app-novinhub
Version:
نوین هاب - پلتفرم کامل مدیریت شبکههای اجتماعی، دایرکت هوشمند، و خودکارسازی پیامرسانی
69 lines • 2.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.novinhubReplyToCommentInDirectAction = 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.novinhubReplyToCommentInDirectAction = (0, apps_framework_1.createAction)({
auth: index_1.novinhubAuth,
name: 'reply_to_comment_in_direct',
displayName: 'پاسخ به کامنت در دایرکت',
description: 'ارسال پیام در دایرکت به کامنتهای اینستاگرام',
props: {
commentId: apps_framework_1.Property.Number({
displayName: 'شناسه کامنت',
description: 'شناسه کامنتی که میخواهید در دایرکت پاسخ دهید',
required: true,
}),
content: apps_framework_1.Property.LongText({
displayName: 'متن پیام',
description: 'محتوای متنی پیام',
required: true,
}),
attachment: apps_framework_1.Property.File({
displayName: 'فایل پیوست',
description: 'فایل ارسالی در پیام (اختیاری)',
required: false,
}),
},
async run(ctx) {
const { commentId, content, attachment } = ctx.propsValue;
const headers = {
'Authorization': `Bearer ${ctx.auth.access_token}`,
};
const formData = new FormData();
formData.append('content', content);
// Add attachment if provided
if (attachment) {
formData.append('attachment', new Blob([attachment.data]), attachment.filename);
}
const url = (0, common_1.buildApiUrl)(`/conversation/comment/${commentId}/reply`);
try {
const response = await apps_common_1.httpClient.sendRequest({
method: apps_common_1.HttpMethod.POST,
url: url,
headers: headers,
body: formData,
});
if (response.status === 200 || response.status === 201) {
return {
success: true,
data: 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=reply-to-comment-in-direct.js.map