<commit_before>"use strict";

var utils = require("../utils");
var log = require("npmlog");

module.exports = function(defaultFuncs, api, ctx) {
  return function changeThreadEmoji(emoji, threadID, callback) {
    var form = {
      'emoji_choice' : emoji,
      'thread_or_other_fbid' : threadID
    };

    defaultFuncs
      .post("https://www.messenger.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
      .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
      .then(function(resData) {
        if (resData.error === 1357031) {
          throw {error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji."};<commit_msg>Fix callback parameter as optional<commit_after>"use strict";

var utils = require("../utils");
var log = require("npmlog");

module.exports = function(defaultFuncs, api, ctx) {
  return function changeThreadEmoji(emoji, threadID, callback) {
    if(!callback) {
      callback = function() {};
    }
    var form = {
      'emoji_choice' : emoji,
      'thread_or_other_fbid' : threadID
    };

    defaultFuncs
      .post("https://www.messenger.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
      .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
      .then(function(resData) {
        if (resData.error === 1357031) {
          throw {error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji."};
{'fraction_non_alphanumeric': 0.12398753894080997, 'fraction_numerical': 0.011214953271028037, 'mean_word_length': 3.7514792899408285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5291387', 'n_tokens_mistral': 526, 'n_tokens_neox': 515, 'n_words': 124}