--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2023 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;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Moq;
+using OpenTween.Connection;
+using Xunit;
+
+namespace OpenTween.Api.GraphQL
+{
+ public class DeleteRetweetRequestTest
+ {
+ [Fact]
+ public async Task Send_Test()
+ {
+ var mock = new Mock<IApiConnection>();
+ mock.Setup(x =>
+ x.PostJsonAsync(It.IsAny<Uri>(), It.IsAny<string>())
+ )
+ .Callback<Uri, string>((url, json) =>
+ {
+ Assert.Equal(new("https://twitter.com/i/api/graphql/iQtK4dl5hBmXewYZuEOKVw/DeleteRetweet"), url);
+ Assert.Contains(@"""source_tweet_id"":""12345""", json);
+ });
+
+ var request = new DeleteRetweetRequest
+ {
+ SourceTweetId = new("12345"),
+ };
+
+ await request.Send(mock.Object).ConfigureAwait(false);
+
+ mock.VerifyAll();
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2023 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.
+
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OpenTween.Connection;
+using OpenTween.Models;
+
+namespace OpenTween.Api.GraphQL
+{
+ public class DeleteRetweetRequest
+ {
+ private static readonly Uri EndpointUri = new("https://twitter.com/i/api/graphql/iQtK4dl5hBmXewYZuEOKVw/DeleteRetweet");
+
+ required public TwitterStatusId SourceTweetId { get; set; }
+
+ public string CreateRequestBody()
+ {
+ return $$"""
+ {"variables":{"source_tweet_id":"{{JsonUtils.EscapeJsonString(this.SourceTweetId.Id)}}","dark_request":false},"queryId":"iQtK4dl5hBmXewYZuEOKVw"}
+ """;
+ }
+
+ public async Task Send(IApiConnection apiConnection)
+ {
+ var json = this.CreateRequestBody();
+ await apiConnection.PostJsonAsync(EndpointUri, json);
+ }
+ }
+}
==== Unreleased
* NEW: Cookie使用時のツイート投稿・削除に対応
- * NEW: Cookie使用時のリツイートに対応
+ * NEW: Cookie使ç\94¨æ\99\82ã\81®ã\83ªã\83\84ã\82¤ã\83¼ã\83\88ã\81\8aã\82\88ã\81³ã\83ªã\83\84ã\82¤ã\83¼ã\83\88ã\81®å\8f\96æ¶\88ã\81«å¯¾å¿\9c
* NEW: graphqlエンドポイントを使用しているタブでの「前データを取得」に対応
* CHG: Google画像検索のURLの変更に対応
{
// 自分が RT したツイート (自分が RT した自分のツイートも含む)
// => RT を取り消し
- await this.tw.Api.StatusesDestroy(post.StatusId.ToTwitterStatusId())
- .IgnoreResponse();
+ await this.tw.DeleteRetweet(post);
}
else
{
};
}
+ public async Task DeleteRetweet(PostClass post)
+ {
+ if (post.RetweetedId == null)
+ throw new ArgumentException("post is not retweeted status", nameof(post));
+
+ if (this.Api.AppToken.AuthType == APIAuthType.TwitterComCookie)
+ {
+ var request = new DeleteRetweetRequest
+ {
+ SourceTweetId = post.RetweetedId.ToTwitterStatusId(),
+ };
+ await request.Send(this.Api.Connection).ConfigureAwait(false);
+ }
+ else
+ {
+ await this.Api.StatusesDestroy(post.StatusId.ToTwitterStatusId())
+ .IgnoreResponse();
+ }
+ }
+
public string Username
=> this.Api.CurrentScreenName;