From 6bfccee2ba5ee31d5b6b857db09d1b784fe20ad9 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Wed, 5 Jul 2023 11:07:48 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=97=E3=83=A9=E3=82=A4=E5=88=B6?= =?UTF-8?q?=E9=99=90=E3=81=95=E3=82=8C=E3=81=9F=E3=83=84=E3=82=A4=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=AERT=E3=81=8CParseTweet=E3=81=A7=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=AA=E3=82=8B=E4=B8=8D=E5=85=B7?= =?UTF-8?q?=E5=90=88=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 5232e94e ("graphqlエンドポイントを使用したリストのタイムライン取得に対応") --- OpenTween/Api/GraphQL/TimelineTweet.cs | 23 ++++++++++++++--------- OpenTween/Resources/ChangeLog.txt | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/OpenTween/Api/GraphQL/TimelineTweet.cs b/OpenTween/Api/GraphQL/TimelineTweet.cs index 8507df49e..f8bb804d3 100644 --- a/OpenTween/Api/GraphQL/TimelineTweet.cs +++ b/OpenTween/Api/GraphQL/TimelineTweet.cs @@ -52,14 +52,7 @@ public TwitterStatus ToTwitterStatus() try { var resultElm = this.Element.Element("tweet_results")?.Element("result") ?? throw CreateParseError(); - var tweetElm = resultElm.Element("__typename")?.Value switch - { - "Tweet" => resultElm, - "TweetWithVisibilityResults" => resultElm.Element("tweet") ?? throw CreateParseError(), - _ => throw CreateParseError(), - }; - - return this.ParseTweet(tweetElm); + return this.ParseTweetUnion(resultElm); } catch (WebApiException ex) { @@ -69,6 +62,18 @@ public TwitterStatus ToTwitterStatus() } } + private TwitterStatus ParseTweetUnion(XElement tweetUnionElm) + { + var tweetElm = tweetUnionElm.Element("__typename")?.Value switch + { + "Tweet" => tweetUnionElm, + "TweetWithVisibilityResults" => tweetUnionElm.Element("tweet") ?? throw CreateParseError(), + _ => throw CreateParseError(), + }; + + return this.ParseTweet(tweetElm); + } + private TwitterStatus ParseTweet(XElement tweetElm) { var tweetLegacyElm = tweetElm.Element("legacy") ?? throw CreateParseError(); @@ -142,7 +147,7 @@ static string GetText(XElement elm, string name) ScreenName = GetText(userLegacyElm, "screen_name"), Protected = GetTextOrNull(userLegacyElm, "protected") == "true", }, - RetweetedStatus = retweetedTweetElm != null ? this.ParseTweet(retweetedTweetElm) : null, + RetweetedStatus = retweetedTweetElm != null ? this.ParseTweetUnion(retweetedTweetElm) : null, }; } diff --git a/OpenTween/Resources/ChangeLog.txt b/OpenTween/Resources/ChangeLog.txt index 06d091410..2d5ec7c62 100644 --- a/OpenTween/Resources/ChangeLog.txt +++ b/OpenTween/Resources/ChangeLog.txt @@ -1,6 +1,7 @@ 更新履歴 ==== Unreleased + * FIX: リプライ制限されたツイートのRTがリストのタイムラインに含まれているとエラーになる不具合を修正 ==== Ver 3.6.1(2023/07/07) * CHG: graphqlエンドポイントからのレスポンスの読み込み失敗時に問題の起きたツイートをErrorLogsに書き出す機能を追加