Mike L 3 лет назад
Родитель
Сommit
6f97eb6470
2 измененных файлов с 16 добавлено и 16 удалено
  1. 7 7
      dist/twitter.js
  2. 9 9
      src/twitter.ts

+ 7 - 7
dist/twitter.js

@@ -256,18 +256,18 @@ class default_1 {
                 return utils_1.chainPromises(utils_1.Arr.chunk(userIdCache, 20).map(userIds => () => {
                     logger.info(`pulling stories from users:${userIds.map(id => ` @${this.cache[id].user.username}`)}`);
                     return this.client.feed.reelsMedia({ userIds }).request()
-                        .then(({ reels }) => utils_1.chainPromises(Object.keys(reels).map(userId => this.cache[userId]).map(cacheItem => () => this.queryUserObject(cacheItem.user.username)
+                        .then(({ reels }) => utils_1.chainPromises(Object.keys(reels).map(userId => this.cache[userId]).map(({ user, stories }) => () => this.queryUserObject(user.username)
                         .catch((error) => {
                         if (error instanceof instagram_private_api_1.IgExactUserNotFoundError) {
-                            return this.client.user.info(cacheItem.user.pk)
+                            return this.client.user.info(user.pk)
                                 .then(({ username, full_name }) => {
-                                cacheItem.user.username = username;
-                                cacheItem.user.full_name = full_name;
+                                user.username = username;
+                                user.full_name = full_name;
                             });
                         }
-                    }).finally(() => Promise.all(reels[cacheItem.user.pk].items
-                        .filter(item => !(item.pk in cacheItem.stories))
-                        .map(item => this.webshot([Object.assign(Object.assign({}, item), { user: cacheItem.user })], (msgs, text, author) => cacheItem.stories[item.pk] = { pk: item.pk, msgs, text, author, original: item }, this.webshotDelay)))))))
+                    }).finally(() => Promise.all(reels[user.pk].items
+                        .filter(item => !(item.pk in stories))
+                        .map(item => this.webshot([Object.assign(Object.assign({}, item), { user })], (msgs, text, author) => stories[item.pk] = { pk: item.pk, msgs, text, author, original: item }, this.webshotDelay)))))))
                         .finally(() => {
                         fs.writeFileSync(path.resolve(this.cachefile), JSON.stringify(this.cache));
                         Object.values(this.lock.threads).forEach(thread => {

+ 9 - 9
src/twitter.ts

@@ -470,22 +470,22 @@ export default class {
             logger.info(`pulling stories from users:${userIds.map(id => ` @${this.cache[id].user.username}`)}`);
             return this.client.feed.reelsMedia({userIds}).request()
               .then(({reels}) => chainPromises(
-                Object.keys(reels).map(userId => this.cache[userId]).map(cacheItem => () =>
-                  this.queryUserObject(cacheItem.user.username)
+                Object.keys(reels).map(userId => this.cache[userId]).map(({user, stories}) => () =>
+                  this.queryUserObject(user.username)
                     .catch((error: IgClientError) => {
                       if (error instanceof IgExactUserNotFoundError) {
-                        return this.client.user.info(cacheItem.user.pk)
+                        return this.client.user.info(user.pk)
                           .then(({username, full_name}) => {
-                            cacheItem.user.username = username;
-                            cacheItem.user.full_name = full_name;
+                            user.username = username;
+                            user.full_name = full_name;
                           });
                       }
-                    }).finally(() => Promise.all(reels[cacheItem.user.pk].items
-                      .filter(item => !(item.pk in cacheItem.stories))
+                    }).finally(() => Promise.all(reels[user.pk].items
+                      .filter(item => !(item.pk in stories))
                       .map(item => this.webshot(
-                        [{...item, user: cacheItem.user}],
+                        [{...item, user}],
                         (msgs: string, text: string, author: string) =>
-                          cacheItem.stories[item.pk] = {pk: item.pk, msgs, text, author, original: item},
+                          stories[item.pk] = {pk: item.pk, msgs, text, author, original: item},
                         this.webshotDelay
                       ))
                     )