UNPKG

@anjir/app-novinhub

Version:

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

70 lines 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.novinhubSearchPeopleAction = 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.novinhubSearchPeopleAction = (0, apps_framework_1.createAction)({ auth: index_1.novinhubAuth, name: 'search_people', displayName: 'جستجوی کاربران', description: 'جستجوی کاربران در شبکه‌های اجتماعی', props: { query: apps_framework_1.Property.ShortText({ displayName: 'متن جستجو', description: 'متن مورد نظر برای جستجوی کاربران', required: true, }), account_ids: apps_framework_1.Property.Array({ displayName: 'شناسه اکانت‌ها', description: 'لیست شناسه اکانت‌هایی که در آن‌ها جستجو شود', required: true, properties: { account_id: apps_framework_1.Property.Number({ displayName: 'شناسه اکانت', description: 'شناسه اکانت', required: true, }), }, }), }, async run(ctx) { const { query, account_ids } = ctx.propsValue; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${ctx.auth.access_token}`, }; const body = { query, account_ids: account_ids.map((item) => item.account_id).join(','), }; const url = (0, common_1.buildApiUrl)('/search/people'); try { const response = await apps_common_1.httpClient.sendRequest({ method: apps_common_1.HttpMethod.POST, url: url, headers: headers, body: body, }); if (response.status === 200) { return { success: true, search_results: 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=search-people.js.map