Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Jun 14, 2024
2 parents 1381ef1 + a27c0ca commit e90935d
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 27 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
更新履歴

==== Ver 3.15.1(2024/06/15)
* FIX: Cookie使用時に「Listの発言取得に公式RTを含める」の設定が適用されない不具合を修正
* FIX: Twitterアカウントでの画像を添付したツイートの投稿がエラーになる不具合を修正
* FIX: 設定画面を閉じた直後に取得されるツイートが全て両思い表示になる不具合を修正

==== Ver 3.15.0(2024/06/14)
* NEW: Misskeyでのノート投稿時のファイル添付に対応しました
- 追加で必要な権限があるため、前バージョンから使用している Misskey アカウントは再度追加し直す必要があります
Expand Down
3 changes: 2 additions & 1 deletion OpenTween.Tests/Api/GraphQL/CreateTweetRequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Moq;
using OpenTween.Connection;
using OpenTween.Models;
using OpenTween.SocialProtocol.Twitter;
using Xunit;

namespace OpenTween.Api.GraphQL
Expand Down Expand Up @@ -104,7 +105,7 @@ public async Task Send_MediaTest()
var request = new CreateTweetRequest
{
TweetText = "tetete",
MediaIds = new[] { "11111", "22222" },
MediaIds = new TwitterMediaId[] { new("11111"), new("22222") },
};
await request.Send(mock.Object);
mock.VerifyAll();
Expand Down
5 changes: 3 additions & 2 deletions OpenTween/Api/GraphQL/CreateTweetRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using OpenTween.Api.DataModel;
using OpenTween.Connection;
using OpenTween.Models;
using OpenTween.SocialProtocol.Twitter;

namespace OpenTween.Api.GraphQL
{
Expand All @@ -43,7 +44,7 @@ public class CreateTweetRequest

public TwitterUserId[] ExcludeReplyUserIds { get; set; } = Array.Empty<TwitterUserId>();

public string[] MediaIds { get; set; } = Array.Empty<string>();
public TwitterMediaId[] MediaIds { get; set; } = Array.Empty<TwitterMediaId>();

public string? AttachmentUrl { get; set; }

Expand Down Expand Up @@ -112,7 +113,7 @@ public string CreateRequestBody()
? new(
MediaEntities: this.MediaIds
.Select(x => new VariableMediaEntity(
MediaId: x,
MediaId: x.Id,
TaggedUsers: Array.Empty<string>()
))
.ToArray(),
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
[assembly: Guid("2d0ae0ba-adac-49a2-9b10-26fd69e695bf")]

[assembly: AssemblyVersion("3.15.0.0")]
[assembly: AssemblyVersion("3.15.1.0")]

[assembly: InternalsVisibleTo("OpenTween.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // for Moq
13 changes: 7 additions & 6 deletions OpenTween/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions OpenTween/SocialProtocol/Misskey/MisskeyAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ISocialProtocolClient ISocialAccount.Client

public bool IsDisposed { get; private set; }

public MisskeyAccountState AccountState { get; private set; } = new();
public MisskeyAccountState AccountState { get; } = new();

ISocialAccountState ISocialAccount.AccountState
=> this.AccountState;
Expand Down Expand Up @@ -71,14 +71,10 @@ public void Initialize(UserAccount accountSettings, SettingCommon settingCommon)
{
Debug.Assert(accountSettings.UniqueKey == this.UniqueKey.Id, "UniqueKey must be same as current value.");

var serverUri = new Uri($"https://{accountSettings.ServerHostname}/");
this.AccountState = new(serverUri, new(accountSettings.UserId), accountSettings.Username)
{
AuthorizedScopes = accountSettings.Scopes,
HasUnrecoverableError = false,
};
this.AccountState.UpdateFromSettings(accountSettings);
this.AccountState.HasUnrecoverableError = false;

var apiBaseUri = new Uri(serverUri, "/api/");
var apiBaseUri = new Uri(this.AccountState.ServerUri, "/api/");

var newConnection = new MisskeyApiConnection(apiBaseUri, accountSettings.TokenSecret, this.AccountState);
(this.connection, var oldConnection) = (newConnection, this.connection);
Expand Down
8 changes: 8 additions & 0 deletions OpenTween/SocialProtocol/Misskey/MisskeyAccountState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public MisskeyAccountState(Uri serverUri, MisskeyUserId userId, string userName)
this.UserName = userName;
}

public void UpdateFromSettings(UserAccount accountSettings)
{
this.ServerUri = new($"https://{accountSettings.ServerHostname}/");
this.UserId = new(accountSettings.UserId);
this.UserName = accountSettings.Username;
this.AuthorizedScopes = accountSettings.Scopes;
}

/// <summary>ユーザー情報を更新します</summary>
public void UpdateFromUser(MisskeyUser self)
{
Expand Down
8 changes: 8 additions & 0 deletions OpenTween/SocialProtocol/Twitter/TimelineResponseFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class TimelineResponseFilter

public bool IsHomeTimeline { get; set; }

public bool IncludeRts { get; set; } = true;

public TimelineResponseFilter(TwitterAccountState accountState)
{
this.accountState = accountState;
Expand All @@ -56,6 +58,9 @@ public PostClass[] Run(PostClass[] posts)
filteredPosts = this.FilterMutedUserPosts(filteredPosts);
}

if (!this.IncludeRts)
filteredPosts = this.FilterRetweets(filteredPosts);

return filteredPosts.ToArray();
}

Expand Down Expand Up @@ -85,5 +90,8 @@ private bool IsMutedPost(PostClass post)

return false;
}

private IEnumerable<PostClass> FilterRetweets(IEnumerable<PostClass> posts)
=> posts.Where(x => x.RetweetedId == null);
}
}
9 changes: 3 additions & 6 deletions OpenTween/SocialProtocol/Twitter/TwitterAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string AccountType

public bool IsDisposed { get; private set; }

public TwitterAccountState AccountState { get; private set; } = new();
public TwitterAccountState AccountState { get; } = new();

ISocialAccountState ISocialAccount.AccountState
=> this.AccountState;
Expand Down Expand Up @@ -72,12 +72,9 @@ public void Initialize(UserAccount accountSettings, SettingCommon settingCommon)
Debug.Assert(accountSettings.UniqueKey == this.UniqueKey.Id, "UniqueKey must be same as current value.");

var credential = accountSettings.GetTwitterCredential();
var userId = new TwitterUserId(accountSettings.UserId);

this.AccountState = new TwitterAccountState(userId, accountSettings.Username)
{
HasUnrecoverableError = credential is TwitterCredentialNone,
};
this.AccountState.UpdateFromSettings(accountSettings);
this.AccountState.HasUnrecoverableError = credential is TwitterCredentialNone;

var newConnection = new TwitterApiConnection(credential, this.AccountState);
(this.apiConnection, var oldConnection) = (newConnection, this.apiConnection);
Expand Down
6 changes: 6 additions & 0 deletions OpenTween/SocialProtocol/Twitter/TwitterAccountState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public TwitterAccountState(TwitterUserId userId, string userName)
this.UserName = userName;
}

public void UpdateFromSettings(UserAccount accountSettings)
{
this.UserId = new(accountSettings.UserId);
this.UserName = accountSettings.Username;
}

/// <summary>ユーザー情報を更新します</summary>
public void UpdateFromUser(TwitterUser self)
{
Expand Down
6 changes: 5 additions & 1 deletion OpenTween/SocialProtocol/Twitter/TwitterGraphqlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using OpenTween.Api.GraphQL;
using OpenTween.Api.TwitterV2;
using OpenTween.Models;
using OpenTween.Setting;

namespace OpenTween.SocialProtocol.Twitter
{
Expand Down Expand Up @@ -177,7 +178,10 @@ public async Task<TimelineResponse> GetListTimeline(long listId, int count, IQue

var posts = this.account.Legacy.CreatePostsFromJson(statuses, firstLoad);

var filter = new TimelineResponseFilter(this.account.AccountState);
var filter = new TimelineResponseFilter(this.account.AccountState)
{
IncludeRts = SettingManager.Instance.Common.IsListsIncludeRts,
};
posts = filter.Run(posts);

return new(posts, cursorTop, cursorBottom);
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/Twitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ await this.SendDirectMessage(param.Text, mediaId)
TweetText = param.Text,
InReplyToTweetId = param.InReplyTo?.StatusId.ToTwitterStatusId(),
ExcludeReplyUserIds = param.ExcludeReplyUserIds.OfType<TwitterUserId>().ToArray(),
MediaIds = param.MediaIds.Select(x => x.ToString()).ToArray(),
MediaIds = param.MediaIds.ToArray(),
AttachmentUrl = param.AttachmentUrl,
};

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 3.14.0.{build}
version: 3.15.0.{build}

os: Visual Studio 2022

Expand Down

0 comments on commit e90935d

Please sign in to comment.