--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// All rights reserved.
+//
+// This file is part of OpenTween.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System.Threading.Tasks;
+using Xunit;
+
+namespace OpenTween.Api.GraphQL
+{
+ public class TimelineResponseTest
+ {
+ [Fact]
+ public async Task ToTwitterStatuses_Test()
+ {
+ using var apiResponse = await TestUtils.CreateApiResponse("Resources/Responses/SearchTimeline_SimpleTweet.json");
+ var tweets = TimelineTweet.ExtractTimelineTweets(await apiResponse.ReadAsJsonXml());
+ var timelineResponse = new TimelineResponse(tweets, "", "");
+
+ var statuses = timelineResponse.ToTwitterStatuses();
+ Assert.Single(statuses);
+ Assert.Equal("1619433164757413894", statuses[0].IdStr);
+ }
+ }
+}
#nullable enable
-using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using OpenTween.Api.DataModel;
namespace OpenTween.Api.GraphQL
{
TimelineTweet[] Tweets,
string? CursorTop,
string? CursorBottom
- );
+ )
+ {
+ public TwitterStatus[] ToTwitterStatuses()
+ => this.Tweets
+ .Where(x => !x.IsTombstone)
+ .Select(x => x.ToTwitterStatus())
+ .ToArray();
+ }
}
var response = await request.Send(this.Api.Connection)
.ConfigureAwait(false);
- statuses = response.Tweets
- .Where(x => !x.IsTombstone)
- .Select(x => x.ToTwitterStatus())
+ statuses = response.ToTwitterStatuses()
.Where(x => x.User.IdStr == userId) // リプライツリーに含まれる他ユーザーのツイートを除外
.ToArray();
var response = await request.Send(this.Api.Connection)
.ConfigureAwait(false);
- var convertedStatuses = response.Tweets
- .Where(x => !x.IsTombstone)
- .Select(x => x.ToTwitterStatus());
+ var convertedStatuses = response.ToTwitterStatuses();
if (!SettingManager.Instance.Common.IsListsIncludeRts)
- convertedStatuses = convertedStatuses.Where(x => x.RetweetedStatus == null);
+ convertedStatuses = convertedStatuses.Where(x => x.RetweetedStatus == null).ToArray();
statuses = convertedStatuses.ToArray();
tab.CursorBottom = response.CursorBottom;
var response = await request.Send(this.Api.Connection)
.ConfigureAwait(false);
- statuses = response.Tweets
- .Where(x => !x.IsTombstone)
- .Select(x => x.ToTwitterStatus())
- .ToArray();
+ statuses = response.ToTwitterStatuses();
}
else
{
var response = await request.Send(this.Api.Connection)
.ConfigureAwait(false);
- statuses = response.Tweets
- .Where(x => !x.IsTombstone)
- .Select(x => x.ToTwitterStatus())
- .ToArray();
+ statuses = response.ToTwitterStatuses();
tab.CursorBottom = response.CursorBottom;