zai-fca 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of zai-fca might be problematic. Click here for more details.
- package/.cache/replit/env/latest +56 -0
- package/.cache/replit/env/latest.json +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/typescript/5.6/node_modules/.package-lock.json +178 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
- package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
- package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
- package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
- package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
- package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
- package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
- package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
- package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
- package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
- package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
- package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
- package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
- package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
- package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
- package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
- package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
- package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
- package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
- package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
- package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
- package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
- package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
- package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
- package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
- package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
- package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/README.md +76 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/index.d.ts +57 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/package.json +50 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
- package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
- package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
- package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
- package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
- package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
- package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
- package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
- package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
- package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
- package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
- package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
- package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
- package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
- package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
- package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
- package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
- package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
- package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
- package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
- package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
- package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
- package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
- package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
- package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
- package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
- package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
- package/.cache/typescript/5.6/package-lock.json +190 -0
- package/.cache/typescript/5.6/package.json +1 -0
- package/.replit +4 -0
- package/.upm/store.json +1 -0
- package/LICENSE +21 -0
- package/README.md +289 -0
- package/index.js +460 -0
- package/package.json +45 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +25 -0
- package/src/addUserToGroup.js +115 -0
- package/src/changeAdminStatus.js +103 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +136 -0
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +76 -0
- package/src/changeBlockedStatus.js +49 -0
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +135 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +59 -0
- package/src/changeThreadColor.js +65 -0
- package/src/changeThreadEmoji.js +55 -0
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +88 -0
- package/src/createPoll.js +71 -0
- package/src/createPost.js +276 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/editMessage.js +59 -0
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +60 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +83 -0
- package/src/getMessage.js +835 -0
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +680 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/listenMqtt.js +827 -0
- package/src/listenMqtt.txt +827 -0
- package/src/logout.js +75 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/muteThread.js +45 -0
- package/src/postFormData.txt +46 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeUserFromGroup.js +79 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchStickers.js +53 -0
- package/src/sendMessage.js +329 -0
- package/src/sendMessageMqtt.js +322 -0
- package/src/sendTypingIndicator.js +101 -0
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/setMessageReaction.js +122 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +112 -0
- package/src/setProfileGuard.js +45 -0
- package/src/setStoryReaction.js +64 -0
- package/src/setTitle.js +90 -0
- package/src/shareContact.js +110 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +23 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +45 -0
- package/src/uploadAttachment.js +94 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/utils.js +2876 -0
    
        package/src/getRegion.js
    ADDED
    
    
| @@ -0,0 +1,680 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            const utils = require("../utils");
         | 
| 4 | 
            +
            // @NethWs3Dev
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            function getExtension(original_extension, filename = "") {
         | 
| 7 | 
            +
              if (original_extension) {
         | 
| 8 | 
            +
                return original_extension;
         | 
| 9 | 
            +
              } else {
         | 
| 10 | 
            +
                const extension = filename.split(".").pop();
         | 
| 11 | 
            +
                if (extension === filename) {
         | 
| 12 | 
            +
                  return "";
         | 
| 13 | 
            +
                } else {
         | 
| 14 | 
            +
                  return extension;
         | 
| 15 | 
            +
                }
         | 
| 16 | 
            +
              }
         | 
| 17 | 
            +
            }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            function formatAttachmentsGraphQLResponse(attachment) {
         | 
| 20 | 
            +
              switch (attachment.__typename) {
         | 
| 21 | 
            +
                case "MessageImage":
         | 
| 22 | 
            +
                  return {
         | 
| 23 | 
            +
                    type: "photo",
         | 
| 24 | 
            +
                    ID: attachment.legacy_attachment_id,
         | 
| 25 | 
            +
                    filename: attachment.filename,
         | 
| 26 | 
            +
                    original_extension: getExtension(
         | 
| 27 | 
            +
                      attachment.original_extension,
         | 
| 28 | 
            +
                      attachment.filename,
         | 
| 29 | 
            +
                    ),
         | 
| 30 | 
            +
                    thumbnailUrl: attachment.thumbnail.uri,
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    previewUrl: attachment.preview.uri,
         | 
| 33 | 
            +
                    previewWidth: attachment.preview.width,
         | 
| 34 | 
            +
                    previewHeight: attachment.preview.height,
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                    largePreviewUrl: attachment.large_preview.uri,
         | 
| 37 | 
            +
                    largePreviewHeight: attachment.large_preview.height,
         | 
| 38 | 
            +
                    largePreviewWidth: attachment.large_preview.width,
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    // You have to query for the real image. See below.
         | 
| 41 | 
            +
                    url: attachment.large_preview.uri, // @Legacy
         | 
| 42 | 
            +
                    width: attachment.large_preview.width, // @Legacy
         | 
| 43 | 
            +
                    height: attachment.large_preview.height, // @Legacy
         | 
| 44 | 
            +
                    name: attachment.filename, // @Legacy
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    // @Undocumented
         | 
| 47 | 
            +
                    attributionApp: attachment.attribution_app
         | 
| 48 | 
            +
                      ? {
         | 
| 49 | 
            +
                          attributionAppID: attachment.attribution_app.id,
         | 
| 50 | 
            +
                          name: attachment.attribution_app.name,
         | 
| 51 | 
            +
                          logo: attachment.attribution_app.square_logo,
         | 
| 52 | 
            +
                        }
         | 
| 53 | 
            +
                      : null,
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    // @TODO No idea what this is, should we expose it?
         | 
| 56 | 
            +
                    //      Ben - July 15th 2017
         | 
| 57 | 
            +
                    // renderAsSticker: attachment.render_as_sticker,
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    // This is _not_ the real URI, this is still just a large preview.
         | 
| 60 | 
            +
                    // To get the URL we'll need to support a POST query to
         | 
| 61 | 
            +
                    //
         | 
| 62 | 
            +
                    //    https://www.facebook.com/webgraphql/query/
         | 
| 63 | 
            +
                    //
         | 
| 64 | 
            +
                    // With the following query params:
         | 
| 65 | 
            +
                    //
         | 
| 66 | 
            +
                    //    query_id:728987990612546
         | 
| 67 | 
            +
                    //    variables:{"id":"100009069356507","photoID":"10213724771692996"}
         | 
| 68 | 
            +
                    //    dpr:1
         | 
| 69 | 
            +
                    //
         | 
| 70 | 
            +
                    // No special form though.
         | 
| 71 | 
            +
                  };
         | 
| 72 | 
            +
                case "MessageAnimatedImage":
         | 
| 73 | 
            +
                  return {
         | 
| 74 | 
            +
                    type: "animated_image",
         | 
| 75 | 
            +
                    ID: attachment.legacy_attachment_id,
         | 
| 76 | 
            +
                    filename: attachment.filename,
         | 
| 77 | 
            +
                    original_extension: getExtension(
         | 
| 78 | 
            +
                      attachment.original_extension,
         | 
| 79 | 
            +
                      attachment.filename,
         | 
| 80 | 
            +
                    ),
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    previewUrl: attachment.preview_image.uri,
         | 
| 83 | 
            +
                    previewWidth: attachment.preview_image.width,
         | 
| 84 | 
            +
                    previewHeight: attachment.preview_image.height,
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                    url: attachment.animated_image.uri,
         | 
| 87 | 
            +
                    width: attachment.animated_image.width,
         | 
| 88 | 
            +
                    height: attachment.animated_image.height,
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                    thumbnailUrl: attachment.preview_image.uri, // @Legacy
         | 
| 91 | 
            +
                    name: attachment.filename, // @Legacy
         | 
| 92 | 
            +
                    facebookUrl: attachment.animated_image.uri, // @Legacy
         | 
| 93 | 
            +
                    rawGifImage: attachment.animated_image.uri, // @Legacy
         | 
| 94 | 
            +
                    animatedGifUrl: attachment.animated_image.uri, // @Legacy
         | 
| 95 | 
            +
                    animatedGifPreviewUrl: attachment.preview_image.uri, // @Legacy
         | 
| 96 | 
            +
                    animatedWebpUrl: attachment.animated_image.uri, // @Legacy
         | 
| 97 | 
            +
                    animatedWebpPreviewUrl: attachment.preview_image.uri, // @Legacy
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                    // @Undocumented
         | 
| 100 | 
            +
                    attributionApp: attachment.attribution_app
         | 
| 101 | 
            +
                      ? {
         | 
| 102 | 
            +
                          attributionAppID: attachment.attribution_app.id,
         | 
| 103 | 
            +
                          name: attachment.attribution_app.name,
         | 
| 104 | 
            +
                          logo: attachment.attribution_app.square_logo,
         | 
| 105 | 
            +
                        }
         | 
| 106 | 
            +
                      : null,
         | 
| 107 | 
            +
                  };
         | 
| 108 | 
            +
                case "MessageVideo":
         | 
| 109 | 
            +
                  return {
         | 
| 110 | 
            +
                    type: "video",
         | 
| 111 | 
            +
                    ID: attachment.legacy_attachment_id,
         | 
| 112 | 
            +
                    filename: attachment.filename,
         | 
| 113 | 
            +
                    original_extension: getExtension(
         | 
| 114 | 
            +
                      attachment.original_extension,
         | 
| 115 | 
            +
                      attachment.filename,
         | 
| 116 | 
            +
                    ),
         | 
| 117 | 
            +
                    duration: attachment.playable_duration_in_ms,
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                    thumbnailUrl: attachment.large_image.uri, // @Legacy
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                    previewUrl: attachment.large_image.uri,
         | 
| 122 | 
            +
                    previewWidth: attachment.large_image.width,
         | 
| 123 | 
            +
                    previewHeight: attachment.large_image.height,
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                    url: attachment.playable_url,
         | 
| 126 | 
            +
                    width: attachment.original_dimensions.x,
         | 
| 127 | 
            +
                    height: attachment.original_dimensions.y,
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                    videoType: attachment.video_type.toLowerCase(),
         | 
| 130 | 
            +
                  };
         | 
| 131 | 
            +
                case "MessageFile":
         | 
| 132 | 
            +
                  return {
         | 
| 133 | 
            +
                    type: "file",
         | 
| 134 | 
            +
                    ID: attachment.message_file_fbid,
         | 
| 135 | 
            +
                    filename: attachment.filename,
         | 
| 136 | 
            +
                    original_extension: getExtension(
         | 
| 137 | 
            +
                      attachment.original_extension,
         | 
| 138 | 
            +
                      attachment.filename,
         | 
| 139 | 
            +
                    ),
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                    url: attachment.url,
         | 
| 142 | 
            +
                    isMalicious: attachment.is_malicious,
         | 
| 143 | 
            +
                    contentType: attachment.content_type,
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                    name: attachment.filename, // @Legacy
         | 
| 146 | 
            +
                    mimeType: "", // @Legacy
         | 
| 147 | 
            +
                    fileSize: -1, // @Legacy
         | 
| 148 | 
            +
                  };
         | 
| 149 | 
            +
                case "MessageAudio":
         | 
| 150 | 
            +
                  return {
         | 
| 151 | 
            +
                    type: "audio",
         | 
| 152 | 
            +
                    ID: attachment.url_shimhash, // Not fowardable
         | 
| 153 | 
            +
                    filename: attachment.filename,
         | 
| 154 | 
            +
                    original_extension: getExtension(
         | 
| 155 | 
            +
                      attachment.original_extension,
         | 
| 156 | 
            +
                      attachment.filename,
         | 
| 157 | 
            +
                    ),
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    duration: attachment.playable_duration_in_ms,
         | 
| 160 | 
            +
                    audioType: attachment.audio_type,
         | 
| 161 | 
            +
                    url: attachment.playable_url,
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                    isVoiceMail: attachment.is_voicemail,
         | 
| 164 | 
            +
                  };
         | 
| 165 | 
            +
                default:
         | 
| 166 | 
            +
                  return {
         | 
| 167 | 
            +
                    error: "Don't know about attachment type " + attachment.__typename,
         | 
| 168 | 
            +
                  };
         | 
| 169 | 
            +
              }
         | 
| 170 | 
            +
            }
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            function formatExtensibleAttachment(attachment) {
         | 
| 173 | 
            +
              if (attachment.story_attachment) {
         | 
| 174 | 
            +
                return {
         | 
| 175 | 
            +
                  type: "share",
         | 
| 176 | 
            +
                  ID: attachment.legacy_attachment_id,
         | 
| 177 | 
            +
                  url: attachment.story_attachment.url,
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                  title: attachment.story_attachment.title_with_entities.text,
         | 
| 180 | 
            +
                  description:
         | 
| 181 | 
            +
                    attachment.story_attachment.description &&
         | 
| 182 | 
            +
                    attachment.story_attachment.description.text,
         | 
| 183 | 
            +
                  source:
         | 
| 184 | 
            +
                    attachment.story_attachment.source == null
         | 
| 185 | 
            +
                      ? null
         | 
| 186 | 
            +
                      : attachment.story_attachment.source.text,
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                  image:
         | 
| 189 | 
            +
                    attachment.story_attachment.media == null
         | 
| 190 | 
            +
                      ? null
         | 
| 191 | 
            +
                      : attachment.story_attachment.media.animated_image == null &&
         | 
| 192 | 
            +
                          attachment.story_attachment.media.image == null
         | 
| 193 | 
            +
                        ? null
         | 
| 194 | 
            +
                        : (
         | 
| 195 | 
            +
                            attachment.story_attachment.media.animated_image ||
         | 
| 196 | 
            +
                            attachment.story_attachment.media.image
         | 
| 197 | 
            +
                          ).uri,
         | 
| 198 | 
            +
                  width:
         | 
| 199 | 
            +
                    attachment.story_attachment.media == null
         | 
| 200 | 
            +
                      ? null
         | 
| 201 | 
            +
                      : attachment.story_attachment.media.animated_image == null &&
         | 
| 202 | 
            +
                          attachment.story_attachment.media.image == null
         | 
| 203 | 
            +
                        ? null
         | 
| 204 | 
            +
                        : (
         | 
| 205 | 
            +
                            attachment.story_attachment.media.animated_image ||
         | 
| 206 | 
            +
                            attachment.story_attachment.media.image
         | 
| 207 | 
            +
                          ).width,
         | 
| 208 | 
            +
                  height:
         | 
| 209 | 
            +
                    attachment.story_attachment.media == null
         | 
| 210 | 
            +
                      ? null
         | 
| 211 | 
            +
                      : attachment.story_attachment.media.animated_image == null &&
         | 
| 212 | 
            +
                          attachment.story_attachment.media.image == null
         | 
| 213 | 
            +
                        ? null
         | 
| 214 | 
            +
                        : (
         | 
| 215 | 
            +
                            attachment.story_attachment.media.animated_image ||
         | 
| 216 | 
            +
                            attachment.story_attachment.media.image
         | 
| 217 | 
            +
                          ).height,
         | 
| 218 | 
            +
                  playable:
         | 
| 219 | 
            +
                    attachment.story_attachment.media == null
         | 
| 220 | 
            +
                      ? null
         | 
| 221 | 
            +
                      : attachment.story_attachment.media.is_playable,
         | 
| 222 | 
            +
                  duration:
         | 
| 223 | 
            +
                    attachment.story_attachment.media == null
         | 
| 224 | 
            +
                      ? null
         | 
| 225 | 
            +
                      : attachment.story_attachment.media.playable_duration_in_ms,
         | 
| 226 | 
            +
                  playableUrl:
         | 
| 227 | 
            +
                    attachment.story_attachment.media == null
         | 
| 228 | 
            +
                      ? null
         | 
| 229 | 
            +
                      : attachment.story_attachment.media.playable_url,
         | 
| 230 | 
            +
             | 
| 231 | 
            +
                  subattachments: attachment.story_attachment.subattachments,
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                  // Format example:
         | 
| 234 | 
            +
                  //
         | 
| 235 | 
            +
                  //   [{
         | 
| 236 | 
            +
                  //     key: "width",
         | 
| 237 | 
            +
                  //     value: { text: "1280" }
         | 
| 238 | 
            +
                  //   }]
         | 
| 239 | 
            +
                  //
         | 
| 240 | 
            +
                  // That we turn into:
         | 
| 241 | 
            +
                  //
         | 
| 242 | 
            +
                  //   {
         | 
| 243 | 
            +
                  //     width: "1280"
         | 
| 244 | 
            +
                  //   }
         | 
| 245 | 
            +
                  //
         | 
| 246 | 
            +
                  properties: attachment.story_attachment.properties.reduce(function (
         | 
| 247 | 
            +
                    obj,
         | 
| 248 | 
            +
                    cur,
         | 
| 249 | 
            +
                  ) {
         | 
| 250 | 
            +
                    obj[cur.key] = cur.value.text;
         | 
| 251 | 
            +
                    return obj;
         | 
| 252 | 
            +
                  }, {}),
         | 
| 253 | 
            +
             | 
| 254 | 
            +
                  // Deprecated fields
         | 
| 255 | 
            +
                  animatedImageSize: "", // @Legacy
         | 
| 256 | 
            +
                  facebookUrl: "", // @Legacy
         | 
| 257 | 
            +
                  styleList: "", // @Legacy
         | 
| 258 | 
            +
                  target: "", // @Legacy
         | 
| 259 | 
            +
                  thumbnailUrl:
         | 
| 260 | 
            +
                    attachment.story_attachment.media == null
         | 
| 261 | 
            +
                      ? null
         | 
| 262 | 
            +
                      : attachment.story_attachment.media.animated_image == null &&
         | 
| 263 | 
            +
                          attachment.story_attachment.media.image == null
         | 
| 264 | 
            +
                        ? null
         | 
| 265 | 
            +
                        : (
         | 
| 266 | 
            +
                            attachment.story_attachment.media.animated_image ||
         | 
| 267 | 
            +
                            attachment.story_attachment.media.image
         | 
| 268 | 
            +
                          ).uri, // @Legacy
         | 
| 269 | 
            +
                  thumbnailWidth:
         | 
| 270 | 
            +
                    attachment.story_attachment.media == null
         | 
| 271 | 
            +
                      ? null
         | 
| 272 | 
            +
                      : attachment.story_attachment.media.animated_image == null &&
         | 
| 273 | 
            +
                          attachment.story_attachment.media.image == null
         | 
| 274 | 
            +
                        ? null
         | 
| 275 | 
            +
                        : (
         | 
| 276 | 
            +
                            attachment.story_attachment.media.animated_image ||
         | 
| 277 | 
            +
                            attachment.story_attachment.media.image
         | 
| 278 | 
            +
                          ).width, // @Legacy
         | 
| 279 | 
            +
                  thumbnailHeight:
         | 
| 280 | 
            +
                    attachment.story_attachment.media == null
         | 
| 281 | 
            +
                      ? null
         | 
| 282 | 
            +
                      : attachment.story_attachment.media.animated_image == null &&
         | 
| 283 | 
            +
                          attachment.story_attachment.media.image == null
         | 
| 284 | 
            +
                        ? null
         | 
| 285 | 
            +
                        : (
         | 
| 286 | 
            +
                            attachment.story_attachment.media.animated_image ||
         | 
| 287 | 
            +
                            attachment.story_attachment.media.image
         | 
| 288 | 
            +
                          ).height, // @Legacy
         | 
| 289 | 
            +
                };
         | 
| 290 | 
            +
              } else {
         | 
| 291 | 
            +
                return { error: "Don't know what to do with extensible_attachment." };
         | 
| 292 | 
            +
              }
         | 
| 293 | 
            +
            }
         | 
| 294 | 
            +
             | 
| 295 | 
            +
            function formatReactionsGraphQL(reaction) {
         | 
| 296 | 
            +
              return {
         | 
| 297 | 
            +
                reaction: reaction.reaction,
         | 
| 298 | 
            +
                userID: reaction.user.id,
         | 
| 299 | 
            +
              };
         | 
| 300 | 
            +
            }
         | 
| 301 | 
            +
             | 
| 302 | 
            +
            function formatEventData(event) {
         | 
| 303 | 
            +
              if (event == null) {
         | 
| 304 | 
            +
                return {};
         | 
| 305 | 
            +
              }
         | 
| 306 | 
            +
             | 
| 307 | 
            +
              switch (event.__typename) {
         | 
| 308 | 
            +
                case "ThemeColorExtensibleMessageAdminText":
         | 
| 309 | 
            +
                  return {
         | 
| 310 | 
            +
                    color: event.theme_color,
         | 
| 311 | 
            +
                  };
         | 
| 312 | 
            +
                case "ThreadNicknameExtensibleMessageAdminText":
         | 
| 313 | 
            +
                  return {
         | 
| 314 | 
            +
                    nickname: event.nickname,
         | 
| 315 | 
            +
                    participantID: event.participant_id,
         | 
| 316 | 
            +
                  };
         | 
| 317 | 
            +
                case "ThreadIconExtensibleMessageAdminText":
         | 
| 318 | 
            +
                  return {
         | 
| 319 | 
            +
                    threadIcon: event.thread_icon,
         | 
| 320 | 
            +
                  };
         | 
| 321 | 
            +
                case "InstantGameUpdateExtensibleMessageAdminText":
         | 
| 322 | 
            +
                  return {
         | 
| 323 | 
            +
                    gameID: event.game == null ? null : event.game.id,
         | 
| 324 | 
            +
                    update_type: event.update_type,
         | 
| 325 | 
            +
                    collapsed_text: event.collapsed_text,
         | 
| 326 | 
            +
                    expanded_text: event.expanded_text,
         | 
| 327 | 
            +
                    instant_game_update_data: event.instant_game_update_data,
         | 
| 328 | 
            +
                  };
         | 
| 329 | 
            +
                case "GameScoreExtensibleMessageAdminText":
         | 
| 330 | 
            +
                  return {
         | 
| 331 | 
            +
                    game_type: event.game_type,
         | 
| 332 | 
            +
                  };
         | 
| 333 | 
            +
                case "RtcCallLogExtensibleMessageAdminText":
         | 
| 334 | 
            +
                  return {
         | 
| 335 | 
            +
                    event: event.event,
         | 
| 336 | 
            +
                    is_video_call: event.is_video_call,
         | 
| 337 | 
            +
                    server_info_data: event.server_info_data,
         | 
| 338 | 
            +
                  };
         | 
| 339 | 
            +
                case "GroupPollExtensibleMessageAdminText":
         | 
| 340 | 
            +
                  return {
         | 
| 341 | 
            +
                    event_type: event.event_type,
         | 
| 342 | 
            +
                    total_count: event.total_count,
         | 
| 343 | 
            +
                    question: event.question,
         | 
| 344 | 
            +
                  };
         | 
| 345 | 
            +
                case "AcceptPendingThreadExtensibleMessageAdminText":
         | 
| 346 | 
            +
                  return {
         | 
| 347 | 
            +
                    accepter_id: event.accepter_id,
         | 
| 348 | 
            +
                    requester_id: event.requester_id,
         | 
| 349 | 
            +
                  };
         | 
| 350 | 
            +
                case "ConfirmFriendRequestExtensibleMessageAdminText":
         | 
| 351 | 
            +
                  return {
         | 
| 352 | 
            +
                    friend_request_recipient: event.friend_request_recipient,
         | 
| 353 | 
            +
                    friend_request_sender: event.friend_request_sender,
         | 
| 354 | 
            +
                  };
         | 
| 355 | 
            +
                case "AddContactExtensibleMessageAdminText":
         | 
| 356 | 
            +
                  return {
         | 
| 357 | 
            +
                    contact_added_id: event.contact_added_id,
         | 
| 358 | 
            +
                    contact_adder_id: event.contact_adder_id,
         | 
| 359 | 
            +
                  };
         | 
| 360 | 
            +
                case "AdExtensibleMessageAdminText":
         | 
| 361 | 
            +
                  return {
         | 
| 362 | 
            +
                    ad_client_token: event.ad_client_token,
         | 
| 363 | 
            +
                    ad_id: event.ad_id,
         | 
| 364 | 
            +
                    ad_preferences_link: event.ad_preferences_link,
         | 
| 365 | 
            +
                    ad_properties: event.ad_properties,
         | 
| 366 | 
            +
                  };
         | 
| 367 | 
            +
                // never data
         | 
| 368 | 
            +
                case "ParticipantJoinedGroupCallExtensibleMessageAdminText":
         | 
| 369 | 
            +
                case "ThreadEphemeralTtlModeExtensibleMessageAdminText":
         | 
| 370 | 
            +
                case "StartedSharingVideoExtensibleMessageAdminText":
         | 
| 371 | 
            +
                case "LightweightEventCreateExtensibleMessageAdminText":
         | 
| 372 | 
            +
                case "LightweightEventNotifyExtensibleMessageAdminText":
         | 
| 373 | 
            +
                case "LightweightEventNotifyBeforeEventExtensibleMessageAdminText":
         | 
| 374 | 
            +
                case "LightweightEventUpdateTitleExtensibleMessageAdminText":
         | 
| 375 | 
            +
                case "LightweightEventUpdateTimeExtensibleMessageAdminText":
         | 
| 376 | 
            +
                case "LightweightEventUpdateLocationExtensibleMessageAdminText":
         | 
| 377 | 
            +
                case "LightweightEventDeleteExtensibleMessageAdminText":
         | 
| 378 | 
            +
                  return {};
         | 
| 379 | 
            +
                default:
         | 
| 380 | 
            +
                  return {
         | 
| 381 | 
            +
                    error: "Don't know what to with event data type " + event.__typename,
         | 
| 382 | 
            +
                  };
         | 
| 383 | 
            +
              }
         | 
| 384 | 
            +
            }
         | 
| 385 | 
            +
             | 
| 386 | 
            +
            function formatMessagesGraphQLResponse(data) {
         | 
| 387 | 
            +
              const messageThread = data.o0.data.message_thread;
         | 
| 388 | 
            +
              const threadID = messageThread.thread_key.thread_fbid
         | 
| 389 | 
            +
                ? messageThread.thread_key.thread_fbid
         | 
| 390 | 
            +
                : messageThread.thread_key.other_user_id;
         | 
| 391 | 
            +
             | 
| 392 | 
            +
              const messages = messageThread.messages.nodes.map(function (d) {
         | 
| 393 | 
            +
                switch (d.__typename) {
         | 
| 394 | 
            +
                  case "UserMessage":
         | 
| 395 | 
            +
                    // Give priority to stickers. They're seen as normal messages but we've
         | 
| 396 | 
            +
                    // been considering them as attachments.
         | 
| 397 | 
            +
                    var maybeStickerAttachment;
         | 
| 398 | 
            +
                    if (d.sticker) {
         | 
| 399 | 
            +
                      maybeStickerAttachment = [
         | 
| 400 | 
            +
                        {
         | 
| 401 | 
            +
                          type: "sticker",
         | 
| 402 | 
            +
                          ID: d.sticker.id,
         | 
| 403 | 
            +
                          url: d.sticker.url,
         | 
| 404 | 
            +
             | 
| 405 | 
            +
                          packID: d.sticker.pack ? d.sticker.pack.id : null,
         | 
| 406 | 
            +
                          spriteUrl: d.sticker.sprite_image,
         | 
| 407 | 
            +
                          spriteUrl2x: d.sticker.sprite_image_2x,
         | 
| 408 | 
            +
                          width: d.sticker.width,
         | 
| 409 | 
            +
                          height: d.sticker.height,
         | 
| 410 | 
            +
             | 
| 411 | 
            +
                          caption: d.snippet, // Not sure what the heck caption was.
         | 
| 412 | 
            +
                          description: d.sticker.label, // Not sure about this one either.
         | 
| 413 | 
            +
             | 
| 414 | 
            +
                          frameCount: d.sticker.frame_count,
         | 
| 415 | 
            +
                          frameRate: d.sticker.frame_rate,
         | 
| 416 | 
            +
                          framesPerRow: d.sticker.frames_per_row,
         | 
| 417 | 
            +
                          framesPerCol: d.sticker.frames_per_col,
         | 
| 418 | 
            +
             | 
| 419 | 
            +
                          stickerID: d.sticker.id, // @Legacy
         | 
| 420 | 
            +
                          spriteURI: d.sticker.sprite_image, // @Legacy
         | 
| 421 | 
            +
                          spriteURI2x: d.sticker.sprite_image_2x, // @Legacy
         | 
| 422 | 
            +
                        },
         | 
| 423 | 
            +
                      ];
         | 
| 424 | 
            +
                    }
         | 
| 425 | 
            +
             | 
| 426 | 
            +
                    var mentionsObj = {};
         | 
| 427 | 
            +
                    if (d.message !== null) {
         | 
| 428 | 
            +
                      d.message.ranges.forEach((e) => {
         | 
| 429 | 
            +
                        mentionsObj[e.entity.id] = d.message.text.substr(
         | 
| 430 | 
            +
                          e.offset,
         | 
| 431 | 
            +
                          e.length,
         | 
| 432 | 
            +
                        );
         | 
| 433 | 
            +
                      });
         | 
| 434 | 
            +
                    }
         | 
| 435 | 
            +
             | 
| 436 | 
            +
                    return {
         | 
| 437 | 
            +
                      type: "message",
         | 
| 438 | 
            +
                      attachments: maybeStickerAttachment
         | 
| 439 | 
            +
                        ? maybeStickerAttachment
         | 
| 440 | 
            +
                        : d.blob_attachments && d.blob_attachments.length > 0
         | 
| 441 | 
            +
                          ? d.blob_attachments.map(formatAttachmentsGraphQLResponse)
         | 
| 442 | 
            +
                          : d.extensible_attachment
         | 
| 443 | 
            +
                            ? [formatExtensibleAttachment(d.extensible_attachment)]
         | 
| 444 | 
            +
                            : [],
         | 
| 445 | 
            +
                      body: d.message !== null ? d.message.text : "",
         | 
| 446 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 447 | 
            +
                      messageID: d.message_id,
         | 
| 448 | 
            +
                      senderID: d.message_sender.id,
         | 
| 449 | 
            +
                      threadID: threadID,
         | 
| 450 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 451 | 
            +
             | 
| 452 | 
            +
                      mentions: mentionsObj,
         | 
| 453 | 
            +
                      isUnread: d.unread,
         | 
| 454 | 
            +
             | 
| 455 | 
            +
                      // New
         | 
| 456 | 
            +
                      messageReactions: d.message_reactions
         | 
| 457 | 
            +
                        ? d.message_reactions.map(formatReactionsGraphQL)
         | 
| 458 | 
            +
                        : null,
         | 
| 459 | 
            +
                      isSponsored: d.is_sponsored,
         | 
| 460 | 
            +
                      snippet: d.snippet,
         | 
| 461 | 
            +
                    };
         | 
| 462 | 
            +
                  case "ThreadNameMessage":
         | 
| 463 | 
            +
                    return {
         | 
| 464 | 
            +
                      type: "event",
         | 
| 465 | 
            +
                      messageID: d.message_id,
         | 
| 466 | 
            +
                      threadID: threadID,
         | 
| 467 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 468 | 
            +
                      senderID: d.message_sender.id,
         | 
| 469 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 470 | 
            +
                      eventType: "change_thread_name",
         | 
| 471 | 
            +
                      snippet: d.snippet,
         | 
| 472 | 
            +
                      eventData: {
         | 
| 473 | 
            +
                        threadName: d.thread_name,
         | 
| 474 | 
            +
                      },
         | 
| 475 | 
            +
             | 
| 476 | 
            +
                      // @Legacy
         | 
| 477 | 
            +
                      author: d.message_sender.id,
         | 
| 478 | 
            +
                      logMessageType: "log:thread-name",
         | 
| 479 | 
            +
                      logMessageData: { name: d.thread_name },
         | 
| 480 | 
            +
                    };
         | 
| 481 | 
            +
                  case "ThreadImageMessage":
         | 
| 482 | 
            +
                    return {
         | 
| 483 | 
            +
                      type: "event",
         | 
| 484 | 
            +
                      messageID: d.message_id,
         | 
| 485 | 
            +
                      threadID: threadID,
         | 
| 486 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 487 | 
            +
                      senderID: d.message_sender.id,
         | 
| 488 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 489 | 
            +
                      eventType: "change_thread_image",
         | 
| 490 | 
            +
                      snippet: d.snippet,
         | 
| 491 | 
            +
                      eventData:
         | 
| 492 | 
            +
                        d.image_with_metadata == null
         | 
| 493 | 
            +
                          ? {} /* removed image */
         | 
| 494 | 
            +
                          : {
         | 
| 495 | 
            +
                              /* image added */
         | 
| 496 | 
            +
                              threadImage: {
         | 
| 497 | 
            +
                                attachmentID: d.image_with_metadata.legacy_attachment_id,
         | 
| 498 | 
            +
                                width: d.image_with_metadata.original_dimensions.x,
         | 
| 499 | 
            +
                                height: d.image_with_metadata.original_dimensions.y,
         | 
| 500 | 
            +
                                url: d.image_with_metadata.preview.uri,
         | 
| 501 | 
            +
                              },
         | 
| 502 | 
            +
                            },
         | 
| 503 | 
            +
             | 
| 504 | 
            +
                      // @Legacy
         | 
| 505 | 
            +
                      logMessageType: "log:thread-icon",
         | 
| 506 | 
            +
                      logMessageData: {
         | 
| 507 | 
            +
                        thread_icon: d.image_with_metadata
         | 
| 508 | 
            +
                          ? d.image_with_metadata.preview.uri
         | 
| 509 | 
            +
                          : null,
         | 
| 510 | 
            +
                      },
         | 
| 511 | 
            +
                    };
         | 
| 512 | 
            +
                  case "ParticipantLeftMessage":
         | 
| 513 | 
            +
                    return {
         | 
| 514 | 
            +
                      type: "event",
         | 
| 515 | 
            +
                      messageID: d.message_id,
         | 
| 516 | 
            +
                      threadID: threadID,
         | 
| 517 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 518 | 
            +
                      senderID: d.message_sender.id,
         | 
| 519 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 520 | 
            +
                      eventType: "remove_participants",
         | 
| 521 | 
            +
                      snippet: d.snippet,
         | 
| 522 | 
            +
                      eventData: {
         | 
| 523 | 
            +
                        // Array of IDs.
         | 
| 524 | 
            +
                        participantsRemoved: d.participants_removed.map(function (p) {
         | 
| 525 | 
            +
                          return p.id;
         | 
| 526 | 
            +
                        }),
         | 
| 527 | 
            +
                      },
         | 
| 528 | 
            +
             | 
| 529 | 
            +
                      // @Legacy
         | 
| 530 | 
            +
                      logMessageType: "log:unsubscribe",
         | 
| 531 | 
            +
                      logMessageData: {
         | 
| 532 | 
            +
                        leftParticipantFbId: d.participants_removed.map(function (p) {
         | 
| 533 | 
            +
                          return p.id;
         | 
| 534 | 
            +
                        }),
         | 
| 535 | 
            +
                      },
         | 
| 536 | 
            +
                    };
         | 
| 537 | 
            +
                  case "ParticipantsAddedMessage":
         | 
| 538 | 
            +
                    return {
         | 
| 539 | 
            +
                      type: "event",
         | 
| 540 | 
            +
                      messageID: d.message_id,
         | 
| 541 | 
            +
                      threadID: threadID,
         | 
| 542 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 543 | 
            +
                      senderID: d.message_sender.id,
         | 
| 544 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 545 | 
            +
                      eventType: "add_participants",
         | 
| 546 | 
            +
                      snippet: d.snippet,
         | 
| 547 | 
            +
                      eventData: {
         | 
| 548 | 
            +
                        // Array of IDs.
         | 
| 549 | 
            +
                        participantsAdded: d.participants_added.map(function (p) {
         | 
| 550 | 
            +
                          return p.id;
         | 
| 551 | 
            +
                        }),
         | 
| 552 | 
            +
                      },
         | 
| 553 | 
            +
             | 
| 554 | 
            +
                      // @Legacy
         | 
| 555 | 
            +
                      logMessageType: "log:subscribe",
         | 
| 556 | 
            +
                      logMessageData: {
         | 
| 557 | 
            +
                        addedParticipants: d.participants_added.map(function (p) {
         | 
| 558 | 
            +
                          return p.id;
         | 
| 559 | 
            +
                        }),
         | 
| 560 | 
            +
                      },
         | 
| 561 | 
            +
                    };
         | 
| 562 | 
            +
                  case "VideoCallMessage":
         | 
| 563 | 
            +
                    return {
         | 
| 564 | 
            +
                      type: "event",
         | 
| 565 | 
            +
                      messageID: d.message_id,
         | 
| 566 | 
            +
                      threadID: threadID,
         | 
| 567 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 568 | 
            +
                      senderID: d.message_sender.id,
         | 
| 569 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 570 | 
            +
                      eventType: "video_call",
         | 
| 571 | 
            +
                      snippet: d.snippet,
         | 
| 572 | 
            +
             | 
| 573 | 
            +
                      // @Legacy
         | 
| 574 | 
            +
                      logMessageType: "other",
         | 
| 575 | 
            +
                    };
         | 
| 576 | 
            +
                  case "VoiceCallMessage":
         | 
| 577 | 
            +
                    return {
         | 
| 578 | 
            +
                      type: "event",
         | 
| 579 | 
            +
                      messageID: d.message_id,
         | 
| 580 | 
            +
                      threadID: threadID,
         | 
| 581 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 582 | 
            +
                      senderID: d.message_sender.id,
         | 
| 583 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 584 | 
            +
                      eventType: "voice_call",
         | 
| 585 | 
            +
                      snippet: d.snippet,
         | 
| 586 | 
            +
             | 
| 587 | 
            +
                      // @Legacy
         | 
| 588 | 
            +
                      logMessageType: "other",
         | 
| 589 | 
            +
                    };
         | 
| 590 | 
            +
                  case "GenericAdminTextMessage":
         | 
| 591 | 
            +
                    return {
         | 
| 592 | 
            +
                      type: "event",
         | 
| 593 | 
            +
                      messageID: d.message_id,
         | 
| 594 | 
            +
                      threadID: threadID,
         | 
| 595 | 
            +
                      isGroup: messageThread.thread_type === "GROUP",
         | 
| 596 | 
            +
                      senderID: d.message_sender.id,
         | 
| 597 | 
            +
                      timestamp: d.timestamp_precise,
         | 
| 598 | 
            +
                      snippet: d.snippet,
         | 
| 599 | 
            +
                      eventType: d.extensible_message_admin_text_type.toLowerCase(),
         | 
| 600 | 
            +
                      eventData: formatEventData(d.extensible_message_admin_text),
         | 
| 601 | 
            +
             | 
| 602 | 
            +
                      // @Legacy
         | 
| 603 | 
            +
                      logMessageType: utils.getAdminTextMessageType(
         | 
| 604 | 
            +
                        d.extensible_message_admin_text_type,
         | 
| 605 | 
            +
                      ),
         | 
| 606 | 
            +
                      logMessageData: d.extensible_message_admin_text, // Maybe different?
         | 
| 607 | 
            +
                    };
         | 
| 608 | 
            +
                  default:
         | 
| 609 | 
            +
                    return { error: "Don't know about message type " + d.__typename };
         | 
| 610 | 
            +
                }
         | 
| 611 | 
            +
              });
         | 
| 612 | 
            +
              return messages;
         | 
| 613 | 
            +
            }
         | 
| 614 | 
            +
             | 
| 615 | 
            +
            module.exports = function (defaultFuncs, api, ctx) {
         | 
| 616 | 
            +
              return function getThreadHistoryGraphQL(
         | 
| 617 | 
            +
                threadID,
         | 
| 618 | 
            +
                amount,
         | 
| 619 | 
            +
                timestamp,
         | 
| 620 | 
            +
                callback,
         | 
| 621 | 
            +
              ) {
         | 
| 622 | 
            +
                let resolveFunc = function () {};
         | 
| 623 | 
            +
                let rejectFunc = function () {};
         | 
| 624 | 
            +
                const returnPromise = new Promise(function (resolve, reject) {
         | 
| 625 | 
            +
                  resolveFunc = resolve;
         | 
| 626 | 
            +
                  rejectFunc = reject;
         | 
| 627 | 
            +
                });
         | 
| 628 | 
            +
             | 
| 629 | 
            +
                if (!callback) {
         | 
| 630 | 
            +
                  callback = function (err, data) {
         | 
| 631 | 
            +
                    if (err) {
         | 
| 632 | 
            +
                      return rejectFunc(err);
         | 
| 633 | 
            +
                    }
         | 
| 634 | 
            +
                    resolveFunc(data);
         | 
| 635 | 
            +
                  };
         | 
| 636 | 
            +
                }
         | 
| 637 | 
            +
             | 
| 638 | 
            +
                // `queries` has to be a string. I couldn't tell from the dev console. This
         | 
| 639 | 
            +
                // took me a really long time to figure out. I deserve a cookie for this.
         | 
| 640 | 
            +
                const form = {
         | 
| 641 | 
            +
                  av: ctx.globalOptions.pageID,
         | 
| 642 | 
            +
                  queries: JSON.stringify({
         | 
| 643 | 
            +
                    o0: {
         | 
| 644 | 
            +
                      // This doc_id was valid on February 2nd 2017.
         | 
| 645 | 
            +
                      doc_id: "1498317363570230",
         | 
| 646 | 
            +
                      query_params: {
         | 
| 647 | 
            +
                        id: threadID,
         | 
| 648 | 
            +
                        message_limit: amount,
         | 
| 649 | 
            +
                        load_messages: 1,
         | 
| 650 | 
            +
                        load_read_receipts: false,
         | 
| 651 | 
            +
                        before: timestamp,
         | 
| 652 | 
            +
                      },
         | 
| 653 | 
            +
                    },
         | 
| 654 | 
            +
                  }),
         | 
| 655 | 
            +
                };
         | 
| 656 | 
            +
             | 
| 657 | 
            +
                defaultFuncs
         | 
| 658 | 
            +
                  .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
         | 
| 659 | 
            +
                  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
         | 
| 660 | 
            +
                  .then(function (resData) {
         | 
| 661 | 
            +
                    if (resData.error) {
         | 
| 662 | 
            +
                      throw resData;
         | 
| 663 | 
            +
                    }
         | 
| 664 | 
            +
                    // This returns us an array of things. The last one is the success /
         | 
| 665 | 
            +
                    // failure one.
         | 
| 666 | 
            +
                    // @TODO What do we do in this case?
         | 
| 667 | 
            +
                    if (resData[resData.length - 1].error_results !== 0) {
         | 
| 668 | 
            +
                      throw new Error("There was an error_result.");
         | 
| 669 | 
            +
                    }
         | 
| 670 | 
            +
             | 
| 671 | 
            +
                    callback(null, formatMessagesGraphQLResponse(resData[0]));
         | 
| 672 | 
            +
                  })
         | 
| 673 | 
            +
                  .catch(function (err) {
         | 
| 674 | 
            +
                    console.error("getThreadHistoryGraphQL", err);
         | 
| 675 | 
            +
                    return callback(err);
         | 
| 676 | 
            +
                  });
         | 
| 677 | 
            +
             | 
| 678 | 
            +
                return returnPromise;
         | 
| 679 | 
            +
              };
         | 
| 680 | 
            +
            };
         |