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 13, 2024
2 parents c3ee35e + 08724f1 commit 1381ef1
Show file tree
Hide file tree
Showing 42 changed files with 614 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
uses: microsoft/setup-msbuild@v2

- name: Set configuration env
shell: pwsh
Expand All @@ -30,7 +30,7 @@ jobs:
echo 'CONFIGURATION=Debug' >> $env:GITHUB_ENV
}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: nuget-${{ hashFiles('*/*.csproj') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
ref: '${{ github.event.pull_request.head.sha }}'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
uses: microsoft/setup-msbuild@v2

- name: Set configuration env
shell: pwsh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
uses: microsoft/setup-msbuild@v2

- name: Set configuration env
shell: pwsh
Expand All @@ -35,7 +35,7 @@ jobs:
echo 'CONFIGURATION=Debug' >> $env:GITHUB_ENV
}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: nuget-${{ hashFiles('*/*.csproj') }}
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
exit $p.ExitCode
}
- uses: codecov/codecov-action@v4.0.0-beta.3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
更新履歴

==== Ver 3.15.0(2024/06/14)
* NEW: Misskeyでのノート投稿時のファイル添付に対応しました
- 追加で必要な権限があるため、前バージョンから使用している Misskey アカウントは再度追加し直す必要があります
* FIX: Favoritesタブが空のまま更新されない不具合を修正
* FIX: 検索タブのクエリ入力欄で日本語入力をオンにできない不具合を修正

==== Ver 3.14.0(2024/06/11)
* NEW: メインアカウント以外のホームタイムライン表示に対応
- タブ単位で切り替わるマルチアカウント機能です
Expand Down
74 changes: 74 additions & 0 deletions OpenTween.Tests/Api/Misskey/DriveFileCreateRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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;
using System.Collections.Generic;
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class DriveFileCreateRequestTest
{
[Fact]
public async Task Send_Test()
{
using var mediaItem = TestUtils.CreateDummyMediaItem();

var response = TestUtils.CreateApiResponse(new MisskeyDriveFile());

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.ThrowIfUnauthorizedScope("write:drive")
);
mock.Setup(x =>
x.SendAsync(It.IsAny<IHttpRequest>())
)
.Callback<IHttpRequest>(x =>
{
var request = Assert.IsType<PostMultipartRequest>(x);
Assert.Equal(new("drive/files/create", UriKind.Relative), request.RequestUri);
var expectedQuery = new Dictionary<string, string>
{
["comment"] = "tetete",
};
Assert.Equal(expectedQuery, request.Query);
var expectedMedia = new Dictionary<string, IMediaItem>
{
["file"] = mediaItem,
};
Assert.Equal(expectedMedia, request.Media);
})
.ReturnsAsync(response);

var request = new DriveFileCreateRequest
{
File = mediaItem,
Comment = "tetete",
};
await request.Send(mock.Object);

mock.VerifyAll();
}
}
}
33 changes: 32 additions & 1 deletion OpenTween.Tests/Api/Misskey/NoteCreateRequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using OpenTween.SocialProtocol.Misskey;
using Xunit;

namespace OpenTween.Api.Misskey
Expand All @@ -43,7 +44,7 @@ public async Task Send_Test()
var request = Assert.IsType<PostJsonRequest>(x);
Assert.Equal(new("notes/create", UriKind.Relative), request.RequestUri);
Assert.Equal(
"""{"replyId":"aaaaa","text":"tetete","visibility":"public"}""",
"""{"fileIds":["bbbbb"],"replyId":"aaaaa","text":"tetete","visibility":"public"}""",
request.JsonString
);
})
Expand All @@ -54,6 +55,36 @@ public async Task Send_Test()
Text = "tetete",
Visibility = "public",
ReplyId = new("aaaaa"),
FileIds = new[] { new MisskeyFileId("bbbbb") },
};
await request.Send(mock.Object);

mock.VerifyAll();
}

[Fact]
public async Task Send_RenoteTest()
{
var response = TestUtils.CreateApiResponse(new MisskeyNote());

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.SendAsync(It.IsAny<IHttpRequest>())
)
.Callback<IHttpRequest>(x =>
{
var request = Assert.IsType<PostJsonRequest>(x);
Assert.Equal(new("notes/create", UriKind.Relative), request.RequestUri);
Assert.Equal(
"""{"renoteId":"aaaaa"}""",
request.JsonString
);
})
.ReturnsAsync(response);

var request = new NoteCreateRequest
{
RenoteId = new("aaaaa"),
};
await request.Send(mock.Object);

Expand Down
13 changes: 7 additions & 6 deletions OpenTween.Tests/Api/TwitterApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using OpenTween.Api.DataModel;
using OpenTween.Connection;
using OpenTween.Models;
using OpenTween.SocialProtocol.Twitter;
using Xunit;

namespace OpenTween.Api
Expand Down Expand Up @@ -275,7 +276,7 @@ public async Task StatusesUpdate_Test()
await twitterApi.StatusesUpdate(
"hogehoge",
replyToId: new("100"),
mediaIds: new[] { 10L, 20L },
mediaIds: new TwitterMediaId[] { new("10"), new("20") },
autoPopulateReplyMetadata: true,
excludeReplyUserIds: new TwitterUserId[] { new("100"), new("200") },
attachmentUrl: "https://twitter.com/twitterapi/status/22634515958"
Expand Down Expand Up @@ -771,7 +772,7 @@ public async Task DirectMessagesEventsNew_Test()
using var twitterApi = new TwitterApi();
twitterApi.ApiConnection = mock.Object;

await twitterApi.DirectMessagesEventsNew(recipientId: new("12345"), text: "hogehoge", mediaId: 67890L);
await twitterApi.DirectMessagesEventsNew(recipientId: new("12345"), text: "hogehoge", mediaId: new("67890"));

mock.VerifyAll();
}
Expand Down Expand Up @@ -1348,7 +1349,7 @@ public async Task MediaUploadAppend_Test()
using var twitterApi = new TwitterApi();
twitterApi.ApiConnection = mock.Object;

await twitterApi.MediaUploadAppend(mediaId: 11111L, segmentIndex: 1, media: media);
await twitterApi.MediaUploadAppend(mediaId: new("11111"), segmentIndex: 1, media: media);

mock.VerifyAll();
}
Expand All @@ -1370,7 +1371,7 @@ public async Task MediaUploadFinalize_Test()
using var twitterApi = new TwitterApi();
twitterApi.ApiConnection = mock.Object;

await twitterApi.MediaUploadFinalize(mediaId: 11111L)
await twitterApi.MediaUploadFinalize(mediaId: new("11111"))
.IgnoreResponse();

mock.VerifyAll();
Expand All @@ -1396,7 +1397,7 @@ public async Task MediaUploadStatus_Test()
using var twitterApi = new TwitterApi();
twitterApi.ApiConnection = mock.Object;

await twitterApi.MediaUploadStatus(mediaId: 11111L);
await twitterApi.MediaUploadStatus(mediaId: new("11111"));

mock.VerifyAll();
}
Expand All @@ -1413,7 +1414,7 @@ public async Task MediaMetadataCreate_Test()
using var twitterApi = new TwitterApi();
twitterApi.ApiConnection = mock.Object;

await twitterApi.MediaMetadataCreate(mediaId: 12345L, altText: "hogehoge");
await twitterApi.MediaMetadataCreate(mediaId: new("12345"), altText: "hogehoge");

mock.VerifyAll();
}
Expand Down
55 changes: 55 additions & 0 deletions OpenTween.Tests/Connection/MisskeyApiConnectionTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 OpenTween.SocialProtocol.Misskey;
using Xunit;

namespace OpenTween.Connection
{
public class MisskeyApiConnectionTest
{
[Fact]
public void ThrowIfUnauthorizedScope_SuccessTest()
{
var accountState = new MisskeyAccountState
{
AuthorizedScopes = new[] { "read:account" },
};
using var apiConnection = new MisskeyApiConnection(new("https://example.com/api/"), "aaa", accountState);

apiConnection.ThrowIfUnauthorizedScope("read:account");
}

[Fact]
public void ThrowIfUnauthorizedScope_ErrorTest()
{
var accountState = new MisskeyAccountState
{
AuthorizedScopes = new[] { "read:account" },
};
using var apiConnection = new MisskeyApiConnection(new("https://example.com/api/"), "aaa", accountState);

Assert.Throws<AdditionalScopeRequiredException>(
() => apiConnection.ThrowIfUnauthorizedScope("write:drive")
);
}
}
}
4 changes: 2 additions & 2 deletions OpenTween.Tests/MediaSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public void SelectedMediaServiceIndex_Test()
mediaSelector.InitializeServices(twAccount);

Assert.Equal("Twitter", mediaSelector.MediaServices[0].Key);
Assert.Equal("Imgur", mediaSelector.MediaServices[1].Key);
Assert.Equal("Imgur", mediaSelector.MediaServices[2].Key);

mediaSelector.SelectedMediaServiceName = "Imgur";
Assert.Equal(1, mediaSelector.SelectedMediaServiceIndex);
Assert.Equal(2, mediaSelector.SelectedMediaServiceIndex);

mediaSelector.SelectedMediaServiceName = "Twitter";
Assert.Equal(0, mediaSelector.SelectedMediaServiceIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ public void CreateParams_RemoveAttachmentUrl_WithMediaTest()
// 引用ツイートと画像添付は併用できないため attachment_url は使用しない(現在は許容されているかも?)
var postParams = new PostStatusParams(Text: "hoge https://twitter.com/twitterapi/status/22634515958")
{
MediaIds = new[] { 1234L },
MediaIds = new[] { new TwitterMediaId("1234") },
};
var expected = new CreateTweetParams(Text: "hoge https://twitter.com/twitterapi/status/22634515958")
{
MediaIds = new[] { 1234L },
MediaIds = new[] { new TwitterMediaId("1234") },
};
Assert.Equal(expected, formatter.CreateParams(postParams));
}
Expand Down
Loading

0 comments on commit 1381ef1

Please sign in to comment.