Skip to content

Commit cda0532

Browse files
committed
TimelineTweetに含まれる引用ツイートの取得に対応
1 parent e016aea commit cda0532

File tree

5 files changed

+456
-1
lines changed

5 files changed

+456
-1
lines changed

CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
更新履歴
22

33
==== Unreleased
4+
* NEW: graphqlエンドポイント経由で取得した引用ツイートの表示に対応
45

56
==== Ver 3.9.0(2023/12/03)
67
* NEW: graphqlエンドポイントに対するレートリミットの表示に対応

OpenTween.Tests/Api/GraphQL/TimelineTweetTest.cs

+28
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,34 @@ public void ToStatus_WithTwitterPostFactory_SelfThread_Test()
139139
Assert.Equal(40480664L, post.UserId);
140140
}
141141

142+
[Fact]
143+
public void ToStatus_WithTwitterPostFactory_QuotedTweet_Test()
144+
{
145+
var rootElm = this.LoadResponseDocument("TimelineTweet_QuotedTweet.json");
146+
var timelineTweet = new TimelineTweet(rootElm);
147+
var status = timelineTweet.ToTwitterStatus();
148+
var postFactory = new TwitterPostFactory(this.CreateTabInfo());
149+
var post = postFactory.CreateFromStatus(status, selfUserId: 1L, new HashSet<long>());
150+
151+
Assert.Equal("1588614645866147840", post.StatusId.Id);
152+
var quotedPostId = Assert.Single(post.QuoteStatusIds);
153+
Assert.Equal("1583108196868116480", quotedPostId.Id);
154+
}
155+
156+
[Fact]
157+
public void ToStatus_WithTwitterPostFactory_QuotedTweet_Tombstone_Test()
158+
{
159+
var rootElm = this.LoadResponseDocument("TimelineTweet_QuotedTweet_Tombstone.json");
160+
var timelineTweet = new TimelineTweet(rootElm);
161+
var status = timelineTweet.ToTwitterStatus();
162+
var postFactory = new TwitterPostFactory(this.CreateTabInfo());
163+
var post = postFactory.CreateFromStatus(status, selfUserId: 1L, new HashSet<long>());
164+
165+
Assert.Equal("1614653321310253057", post.StatusId.Id);
166+
var quotedPostId = Assert.Single(post.QuoteStatusIds);
167+
Assert.Equal("1614650279194136576", quotedPostId.Id);
168+
}
169+
142170
[Fact]
143171
public void ToStatus_WithTwitterPostFactory_PromotedTweet_Test()
144172
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
{
2+
"itemType": "TimelineTweet",
3+
"__typename": "TimelineTweet",
4+
"tweet_results": {
5+
"result": {
6+
"__typename": "Tweet",
7+
"rest_id": "1588614645866147840",
8+
"has_birdwatch_notes": false,
9+
"core": {
10+
"user_results": {
11+
"result": {
12+
"__typename": "User",
13+
"id": "VXNlcjo0MDQ4MDY2NA==",
14+
"rest_id": "40480664",
15+
"affiliates_highlighted_label": {},
16+
"has_graduated_access": false,
17+
"is_blue_verified": false,
18+
"profile_image_shape": "Circle",
19+
"legacy": {
20+
"can_dm": true,
21+
"can_media_tag": true,
22+
"created_at": "Sat May 16 15:20:01 +0000 2009",
23+
"default_profile": false,
24+
"default_profile_image": false,
25+
"description": "",
26+
"entities": {
27+
"description": {
28+
"urls": []
29+
},
30+
"url": {
31+
"urls": [
32+
{
33+
"display_url": "m.upsilo.net/@upsilon",
34+
"expanded_url": "https://m.upsilo.net/@upsilon",
35+
"url": "https://t.co/vNMmyHHh15",
36+
"indices": [
37+
0,
38+
23
39+
]
40+
}
41+
]
42+
}
43+
},
44+
"fast_followers_count": 0,
45+
"favourites_count": 215369,
46+
"followers_count": 1287,
47+
"friends_count": 1,
48+
"has_custom_timelines": false,
49+
"is_translator": false,
50+
"listed_count": 92,
51+
"location": "Funabashi, Chiba, Japan",
52+
"media_count": 876,
53+
"name": "upsilon",
54+
"needs_phone_verification": false,
55+
"normal_followers_count": 1287,
56+
"pinned_tweet_ids_str": [],
57+
"possibly_sensitive": false,
58+
"profile_banner_url": "https://pbs.twimg.com/profile_banners/40480664/1349188016",
59+
"profile_image_url_https": "https://pbs.twimg.com/profile_images/719076434/____normal.png",
60+
"profile_interstitial_type": "",
61+
"screen_name": "kim_upsilon",
62+
"statuses_count": 10081,
63+
"translator_type": "regular",
64+
"url": "https://t.co/vNMmyHHh15",
65+
"verified": false,
66+
"want_retweets": false,
67+
"withheld_in_countries": []
68+
}
69+
}
70+
}
71+
},
72+
"unmention_data": {},
73+
"unified_card": {
74+
"card_fetch_state": "NoCard"
75+
},
76+
"edit_control": {
77+
"edit_tweet_ids": [
78+
"1588614645866147840"
79+
],
80+
"editable_until_msecs": "1667592021000",
81+
"is_edit_eligible": false,
82+
"edits_remaining": "5"
83+
},
84+
"is_translatable": true,
85+
"views": {
86+
"state": "Enabled"
87+
},
88+
"source": "<a href=\"https://www.opentween.org/\" rel=\"nofollow\">OpenTween (dev)</a>",
89+
"quoted_status_result": {
90+
"result": {
91+
"__typename": "Tweet",
92+
"rest_id": "1583108196868116480",
93+
"has_birdwatch_notes": false,
94+
"core": {
95+
"user_results": {
96+
"result": {
97+
"__typename": "User",
98+
"id": "VXNlcjo0MDQ4MDY2NA==",
99+
"rest_id": "40480664",
100+
"affiliates_highlighted_label": {},
101+
"has_graduated_access": false,
102+
"is_blue_verified": false,
103+
"profile_image_shape": "Circle",
104+
"legacy": {
105+
"can_dm": true,
106+
"can_media_tag": true,
107+
"created_at": "Sat May 16 15:20:01 +0000 2009",
108+
"default_profile": false,
109+
"default_profile_image": false,
110+
"description": "",
111+
"entities": {
112+
"description": {
113+
"urls": []
114+
},
115+
"url": {
116+
"urls": [
117+
{
118+
"display_url": "m.upsilo.net/@upsilon",
119+
"expanded_url": "https://m.upsilo.net/@upsilon",
120+
"url": "https://t.co/vNMmyHHh15",
121+
"indices": [
122+
0,
123+
23
124+
]
125+
}
126+
]
127+
}
128+
},
129+
"fast_followers_count": 0,
130+
"favourites_count": 215369,
131+
"followers_count": 1287,
132+
"friends_count": 1,
133+
"has_custom_timelines": false,
134+
"is_translator": false,
135+
"listed_count": 92,
136+
"location": "Funabashi, Chiba, Japan",
137+
"media_count": 876,
138+
"name": "upsilon",
139+
"needs_phone_verification": false,
140+
"normal_followers_count": 1287,
141+
"pinned_tweet_ids_str": [],
142+
"possibly_sensitive": false,
143+
"profile_banner_url": "https://pbs.twimg.com/profile_banners/40480664/1349188016",
144+
"profile_image_url_https": "https://pbs.twimg.com/profile_images/719076434/____normal.png",
145+
"profile_interstitial_type": "",
146+
"screen_name": "kim_upsilon",
147+
"statuses_count": 10081,
148+
"translator_type": "regular",
149+
"url": "https://t.co/vNMmyHHh15",
150+
"verified": false,
151+
"want_retweets": false,
152+
"withheld_in_countries": []
153+
}
154+
}
155+
}
156+
},
157+
"unmention_data": {},
158+
"edit_control": {
159+
"edit_tweet_ids": [
160+
"1583108196868116480"
161+
],
162+
"editable_until_msecs": "1666279181000",
163+
"is_edit_eligible": true,
164+
"edits_remaining": "5"
165+
},
166+
"is_translatable": true,
167+
"views": {
168+
"state": "Enabled"
169+
},
170+
"source": "<a href=\"https://www.opentween.org/\" rel=\"nofollow\">OpenTween (dev)</a>",
171+
"legacy": {
172+
"bookmark_count": 0,
173+
"bookmarked": false,
174+
"created_at": "Thu Oct 20 14:49:41 +0000 2022",
175+
"conversation_id_str": "1583108196868116480",
176+
"display_text_range": [
177+
0,
178+
97
179+
],
180+
"entities": {
181+
"user_mentions": [],
182+
"urls": [],
183+
"hashtags": [],
184+
"symbols": []
185+
},
186+
"favorite_count": 2,
187+
"favorited": false,
188+
"full_text": "AppVeyorでビルドした時と自分の開発環境でビルドした時でなぜか sgen.exe の出力が異なって生成物のハッシュ値が一致しなくなる問題に悩み中。Reproducible Buildむずい",
189+
"is_quote_status": false,
190+
"lang": "ja",
191+
"quote_count": 1,
192+
"reply_count": 0,
193+
"retweet_count": 0,
194+
"retweeted": false,
195+
"user_id_str": "40480664",
196+
"id_str": "1583108196868116480"
197+
}
198+
}
199+
},
200+
"legacy": {
201+
"bookmark_count": 0,
202+
"bookmarked": false,
203+
"created_at": "Fri Nov 04 19:30:21 +0000 2022",
204+
"conversation_id_str": "1588614645866147840",
205+
"display_text_range": [
206+
0,
207+
63
208+
],
209+
"entities": {
210+
"user_mentions": [],
211+
"urls": [
212+
{
213+
"display_url": "twitter.com/kim_upsilon/st…",
214+
"expanded_url": "https://twitter.com/kim_upsilon/status/1583108196868116480",
215+
"url": "https://t.co/mb89Ecojqd",
216+
"indices": [
217+
40,
218+
63
219+
]
220+
}
221+
],
222+
"hashtags": [],
223+
"symbols": []
224+
},
225+
"favorite_count": 2,
226+
"favorited": false,
227+
"full_text": "これ結局原因が分からないまま sgen.exe を使うのを止めることで解決した https://t.co/mb89Ecojqd",
228+
"is_quote_status": true,
229+
"lang": "ja",
230+
"possibly_sensitive": false,
231+
"possibly_sensitive_editable": true,
232+
"quote_count": 0,
233+
"quoted_status_id_str": "1583108196868116480",
234+
"quoted_status_permalink": {
235+
"url": "https://t.co/mb89Ecojqd",
236+
"expanded": "https://twitter.com/kim_upsilon/status/1583108196868116480",
237+
"display": "twitter.com/kim_upsilon/st…"
238+
},
239+
"reply_count": 1,
240+
"retweet_count": 0,
241+
"retweeted": false,
242+
"user_id_str": "40480664",
243+
"id_str": "1588614645866147840"
244+
},
245+
"quick_promote_eligibility": {
246+
"eligibility": "IneligibleNotProfessional"
247+
}
248+
}
249+
},
250+
"tweetDisplayType": "SelfThread",
251+
"hasModeratedReplies": false
252+
}

0 commit comments

Comments
 (0)