constructor(params) { params.jar = params.jar || 'string'; const comparator = function (needle, haystack) { if (Array.isArray(haystack)) { return haystack.filter(part => part.indexOf(needle) >= 0).length > 0; } return haystack.indexOf(needle) >= 0; }; super(comparator, params); this.params.type = 'to include'; }
defaultFuncs .post("https://www.facebook.com/chat/user_info/", ctx.jar, form) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(null, formatData(resData.payload.profiles)); }) .catch(function(err) { log.error("getUserInfo", err); return callback(err); });
getException() { const params = this.params; params.jar = template(params.jar, params); const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} "{{expected}}" {{type}} "{{actual}}"'); err.showDiff = false; if (typeof err.cliMessage === 'function') { err.message = err.cliMessage(); } err.cliMessage = () => { const msg = err.template .replace('{{jar}}', output.colors.bold('{{jar}}')); return template(msg, this.params); }; return err; }
getException() { const params = this.params; params.jar = template(params.jar, params); const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} {{type}} "{{needle}}"'); err.expected = params.needle; err.actual = params.haystack; if (Array.isArray(this.params.haystack)) { this.params.haystack = this.params.haystack.join('\n___(next element)___\n'); } err.cliMessage = function () { const msg = this.template .replace('{{jar}}', output.colors.bold('{{jar}}')) .replace('{{needle}}', output.colors.bold('{{needle}}')); return template(msg, this.params); }; return err; }
defaultFuncs .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID }) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(resData => { if (resData.error) { throw resData; } var photoUrl = resData.jsmods.require[0][3][0]; return callback(null, photoUrl); }) .catch(err => { log.error("resolvePhotoUrl", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.payload.status != "success") { throw resData; } return callback(); }) .catch(function(err) { log.error("createPoll", err); return callback(err); });
defaultFuncs .get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } var data = resData.payload.entries; callback(null, data.map(formatData)); }) .catch(function(err) { log.error("getUserID", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/mercury/attachments/forward/", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(null); }) .catch(function(err) { log.error("forwardAttachment", err); return callback(err); });
defaultFuncs .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (!resData) { throw { error: "Remove from group failed." }; } if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("removeUserFromGroup", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("changeArchivedStatus", err); return callback(err); });
defaultFuncs .post("https://www.facebook.com/messaging/send/", ctx.jar, form) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (!resData) { throw { error: "Add to group failed." }; } if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("addUserToGroup", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/ajax/mercury/move_thread.php", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("handleMessageRequest", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/messaging/unsend_message/", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("unsendMessage", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("deleteMessage", err); return callback(err); });
defaultFuncs .post( "https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form ) .then(utils.parseAndCheckLogin(ctx, defaultFuncs)) .then(function(resData) { if (resData.error) { throw resData; } return callback(); }) .catch(function(err) { log.error("deleteThread", err); return callback(err); });