@jikey/fcazero
Version:
Facebook Messenger bot, and is one of the most advanced next-generation Facebook Chat API (FCA)
2 lines (1 loc) • 2.02 kB
JavaScript
;var f=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var D=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},u=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of g(e))!v.call(r,a)&&a!==t&&s(r,a,{get:()=>e[a],enumerable:!(o=m(e,a))||o.enumerable});return r};var S=(r,e,t)=>(t=r!=null?f(_(r)):{},u(e||!r||!r.__esModule?s(t,"default",{value:r,enumerable:!0}):t,r)),w=r=>u(s({},"__esModule",{value:!0}),r);var I={};D(I,{default:()=>h});module.exports=w(I);var n=require("../utils/constants.js"),d=S(require("../utils/logger.js"),1),p=require("./core/mqttPublish.js");class h{constructor(e,t,o){this.ctx=o}call(e,t){return new Promise(async(o,a)=>{try{if(!e.threadID)throw new Error("please pass a threadID as a second argument.");if(n.Constants.getType(e.threadID)!=="Number"&&n.Constants.getType(e.threadID)!=="String")throw new Error("threadID must be a number or a string");if(typeof e.archived!="boolean")throw new Error("archived must be a boolean");if(this.ctx.mqttClient?.connected){const i=JSON.stringify({app_id:"772021112871879",payload:JSON.stringify({tasks:[{failure_count:null,label:"146",payload:JSON.stringify({thread_key:e.threadID,remove_type:1,sync_group:1}),queue_name:e.threadID,task_id:Date.now()}],version_id:"24071272362557704"}),request_id:Date.now(),type:3}),y=JSON.stringify({app_id:"772021112871879",payload:JSON.stringify({tasks:[{failure_count:null,label:"242",payload:JSON.stringify({thread_id:e.threadID,sync_group:1}),queue_name:"unarchive_thread",task_id:Date.now()}],version_id:"24071272362557704"}),request_id:Date.now(),type:3}),c=e.archived?i:y,l=await(0,p.sendRequest)(this.ctx.mqttClient,"/ls_req","/ls_resp",c);t&&typeof t=="function"&&t(null,l),o()}}catch(i){d.default.error({error:i},"Error occurred while changing archived status"),t&&typeof t=="function"&&t(i instanceof Error?i:new Error(String(i))),a(i)}})}}