rettiwt-api 4.1.2 → 4.1.4
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.
- package/dist/models/data/Tweet.js +24 -19
- package/dist/models/data/Tweet.js.map +1 -1
- package/package.json +2 -2
- package/src/models/data/Tweet.ts +30 -23
|
@@ -42,23 +42,19 @@ var Tweet = /** @class */ (function () {
|
|
|
42
42
|
* @returns - The deserialized original quoted tweet.
|
|
43
43
|
*/
|
|
44
44
|
Tweet.prototype.getQuotedTweet = function (tweet) {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f;
|
|
45
46
|
// If tweet with limited visibility
|
|
46
47
|
if (tweet.quoted_status_result &&
|
|
47
|
-
|
|
48
|
-
tweet.quoted_status_result.result.
|
|
48
|
+
((_b = (_a = tweet.quoted_status_result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.__typename) == 'TweetWithVisibilityResults' &&
|
|
49
|
+
((_d = (_c = tweet.quoted_status_result.result) === null || _c === void 0 ? void 0 : _c.tweet) === null || _d === void 0 ? void 0 : _d.legacy)) {
|
|
49
50
|
return new Tweet(tweet.quoted_status_result.result.tweet);
|
|
50
51
|
}
|
|
51
52
|
// If normal tweet
|
|
52
|
-
else if (
|
|
53
|
-
return new Tweet(tweet);
|
|
53
|
+
else if ((_f = (_e = tweet.quoted_status_result) === null || _e === void 0 ? void 0 : _e.result) === null || _f === void 0 ? void 0 : _f.rest_id) {
|
|
54
|
+
return new Tweet(tweet.quoted_status_result.result);
|
|
54
55
|
}
|
|
55
56
|
// Else, skip
|
|
56
57
|
else {
|
|
57
|
-
// Logging
|
|
58
|
-
LogService_1.LogService.log(Logging_1.ELogActions.WARNING, {
|
|
59
|
-
action: Logging_1.ELogActions.DESERIALIZE,
|
|
60
|
-
message: 'Quoted tweet not found, skipping',
|
|
61
|
-
});
|
|
62
58
|
return undefined;
|
|
63
59
|
}
|
|
64
60
|
};
|
|
@@ -70,18 +66,19 @@ var Tweet = /** @class */ (function () {
|
|
|
70
66
|
* @returns - The deserialized original retweeted tweet.
|
|
71
67
|
*/
|
|
72
68
|
Tweet.prototype.getRetweetedTweet = function (tweet) {
|
|
73
|
-
var _a, _b;
|
|
74
|
-
// If
|
|
75
|
-
if ((
|
|
69
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
70
|
+
// If retweet with limited visibility
|
|
71
|
+
if (((_a = tweet.legacy) === null || _a === void 0 ? void 0 : _a.retweeted_status_result) &&
|
|
72
|
+
((_d = (_c = (_b = tweet.legacy) === null || _b === void 0 ? void 0 : _b.retweeted_status_result) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.__typename) == 'TweetWithVisibilityResults' &&
|
|
73
|
+
((_h = (_g = (_f = (_e = tweet.legacy) === null || _e === void 0 ? void 0 : _e.retweeted_status_result) === null || _f === void 0 ? void 0 : _f.result) === null || _g === void 0 ? void 0 : _g.tweet) === null || _h === void 0 ? void 0 : _h.legacy)) {
|
|
74
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result.tweet);
|
|
75
|
+
}
|
|
76
|
+
// If normal tweet
|
|
77
|
+
else if ((_l = (_k = (_j = tweet.legacy) === null || _j === void 0 ? void 0 : _j.retweeted_status_result) === null || _k === void 0 ? void 0 : _k.result) === null || _l === void 0 ? void 0 : _l.rest_id) {
|
|
76
78
|
return new Tweet(tweet.legacy.retweeted_status_result.result);
|
|
77
79
|
}
|
|
78
80
|
// Else, skip
|
|
79
81
|
else {
|
|
80
|
-
// Logging
|
|
81
|
-
LogService_1.LogService.log(Logging_1.ELogActions.WARNING, {
|
|
82
|
-
action: Logging_1.ELogActions.DESERIALIZE,
|
|
83
|
-
message: 'Retweeted tweet not found, skipping',
|
|
84
|
-
});
|
|
85
82
|
return undefined;
|
|
86
83
|
}
|
|
87
84
|
};
|
|
@@ -95,18 +92,26 @@ var Tweet = /** @class */ (function () {
|
|
|
95
92
|
* @internal
|
|
96
93
|
*/
|
|
97
94
|
Tweet.list = function (response) {
|
|
98
|
-
var _a, _b;
|
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
99
96
|
var tweets = [];
|
|
100
97
|
// Extracting the matching data
|
|
101
98
|
var extract = (0, JsonUtils_1.findByFilter)(response, '__typename', 'TimelineTweet');
|
|
102
99
|
// Deserializing valid data
|
|
103
100
|
for (var _i = 0, extract_1 = extract; _i < extract_1.length; _i++) {
|
|
104
101
|
var item = extract_1[_i];
|
|
105
|
-
|
|
102
|
+
// If tweet with limited visibility
|
|
103
|
+
if (((_a = item.tweet_results) === null || _a === void 0 ? void 0 : _a.result) &&
|
|
104
|
+
((_c = (_b = item.tweet_results) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.__typename) == 'TweetWithVisibilityResults' &&
|
|
105
|
+
((_f = (_e = (_d = item.tweet_results) === null || _d === void 0 ? void 0 : _d.result) === null || _e === void 0 ? void 0 : _e.tweet) === null || _f === void 0 ? void 0 : _f.legacy)) {
|
|
106
|
+
tweets.push(new Tweet(item.tweet_results.result.tweet));
|
|
107
|
+
}
|
|
108
|
+
// If normal tweet
|
|
109
|
+
else if ((_h = (_g = item.tweet_results) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.legacy) {
|
|
106
110
|
// Logging
|
|
107
111
|
LogService_1.LogService.log(Logging_1.ELogActions.DESERIALIZE, { id: item.tweet_results.result.rest_id });
|
|
108
112
|
tweets.push(new Tweet(item.tweet_results.result));
|
|
109
113
|
}
|
|
114
|
+
// If invalid/unrecognized tweet
|
|
110
115
|
else {
|
|
111
116
|
// Logging
|
|
112
117
|
LogService_1.LogService.log(Logging_1.ELogActions.WARNING, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/models/data/Tweet.ts"],"names":[],"mappings":";;;AAAA,6CAQsB;AAEtB,+CAAkD;AAClD,oDAAsD;AAEtD,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U"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"description": "An API for fetching data from TwitterAPI, without any rate limits!",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"commander": "11.1.0",
|
|
37
37
|
"https-proxy-agent": "7.0.2",
|
|
38
38
|
"rettiwt-auth": "2.1.0",
|
|
39
|
-
"rettiwt-core": "4.3.
|
|
39
|
+
"rettiwt-core": "4.3.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.4.1",
|
package/src/models/data/Tweet.ts
CHANGED
|
@@ -102,23 +102,17 @@ export class Tweet {
|
|
|
102
102
|
// If tweet with limited visibility
|
|
103
103
|
if (
|
|
104
104
|
tweet.quoted_status_result &&
|
|
105
|
-
|
|
106
|
-
tweet.quoted_status_result.result
|
|
105
|
+
tweet.quoted_status_result?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
106
|
+
(tweet.quoted_status_result.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
107
107
|
) {
|
|
108
108
|
return new Tweet((tweet.quoted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
109
109
|
}
|
|
110
110
|
// If normal tweet
|
|
111
|
-
else if (tweet.quoted_status_result
|
|
112
|
-
return new Tweet(tweet);
|
|
111
|
+
else if ((tweet.quoted_status_result?.result as ITweet)?.rest_id) {
|
|
112
|
+
return new Tweet(tweet.quoted_status_result.result as ITweet);
|
|
113
113
|
}
|
|
114
114
|
// Else, skip
|
|
115
115
|
else {
|
|
116
|
-
// Logging
|
|
117
|
-
LogService.log(ELogActions.WARNING, {
|
|
118
|
-
action: ELogActions.DESERIALIZE,
|
|
119
|
-
message: 'Quoted tweet not found, skipping',
|
|
120
|
-
});
|
|
121
|
-
|
|
122
116
|
return undefined;
|
|
123
117
|
}
|
|
124
118
|
}
|
|
@@ -131,18 +125,20 @@ export class Tweet {
|
|
|
131
125
|
* @returns - The deserialized original retweeted tweet.
|
|
132
126
|
*/
|
|
133
127
|
private getRetweetedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
134
|
-
// If
|
|
135
|
-
if (
|
|
136
|
-
|
|
128
|
+
// If retweet with limited visibility
|
|
129
|
+
if (
|
|
130
|
+
tweet.legacy?.retweeted_status_result &&
|
|
131
|
+
tweet.legacy?.retweeted_status_result?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
132
|
+
(tweet.legacy?.retweeted_status_result?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
133
|
+
) {
|
|
134
|
+
return new Tweet((tweet.legacy.retweeted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
135
|
+
}
|
|
136
|
+
// If normal tweet
|
|
137
|
+
else if ((tweet.legacy?.retweeted_status_result?.result as ITweet)?.rest_id) {
|
|
138
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result as ITweet);
|
|
137
139
|
}
|
|
138
140
|
// Else, skip
|
|
139
141
|
else {
|
|
140
|
-
// Logging
|
|
141
|
-
LogService.log(ELogActions.WARNING, {
|
|
142
|
-
action: ELogActions.DESERIALIZE,
|
|
143
|
-
message: 'Retweeted tweet not found, skipping',
|
|
144
|
-
});
|
|
145
|
-
|
|
146
142
|
return undefined;
|
|
147
143
|
}
|
|
148
144
|
}
|
|
@@ -164,12 +160,23 @@ export class Tweet {
|
|
|
164
160
|
|
|
165
161
|
// Deserializing valid data
|
|
166
162
|
for (const item of extract) {
|
|
167
|
-
|
|
163
|
+
// If tweet with limited visibility
|
|
164
|
+
if (
|
|
165
|
+
item.tweet_results?.result &&
|
|
166
|
+
item.tweet_results?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
167
|
+
(item.tweet_results?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
168
|
+
) {
|
|
169
|
+
tweets.push(new Tweet((item.tweet_results.result as ILimitedVisibilityTweet).tweet));
|
|
170
|
+
}
|
|
171
|
+
// If normal tweet
|
|
172
|
+
else if ((item.tweet_results?.result as ITweet)?.legacy) {
|
|
168
173
|
// Logging
|
|
169
|
-
LogService.log(ELogActions.DESERIALIZE, { id: item.tweet_results.result.rest_id });
|
|
174
|
+
LogService.log(ELogActions.DESERIALIZE, { id: (item.tweet_results.result as ITweet).rest_id });
|
|
170
175
|
|
|
171
|
-
tweets.push(new Tweet(item.tweet_results.result));
|
|
172
|
-
}
|
|
176
|
+
tweets.push(new Tweet(item.tweet_results.result as ITweet));
|
|
177
|
+
}
|
|
178
|
+
// If invalid/unrecognized tweet
|
|
179
|
+
else {
|
|
173
180
|
// Logging
|
|
174
181
|
LogService.log(ELogActions.WARNING, {
|
|
175
182
|
action: ELogActions.DESERIALIZE,
|