Skip to content

Commit

Permalink
Merge pull request #362 from opentween/misskey
Browse files Browse the repository at this point in the history
Misskeyアカウントのホームタイムライン閲覧・投稿に対応
  • Loading branch information
upsilon authored Jun 10, 2024
2 parents 0c20d60 + 3403fbb commit 8132f06
Show file tree
Hide file tree
Showing 55 changed files with 3,467 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- タブ単位で切り替わるマルチアカウント機能です
- 投稿欄やふぁぼ・RT等の機能も表示中のタブに連動して使用するアカウントが変わります
- 現時点ではメインアカウント以外のタブ設定は次回起動時に保持されません
* NEW: Misskeyアカウントのホームタイムライン表示・投稿に対応しました
- 現時点では Misskey アカウントをメインに設定することはできません
- MFMの表示には対応していません
* NEW: Twemoji 15.1.0 に対応しました
- Unicode 15.1 で追加された絵文字が表示されるようになります
* NEW: WebP画像の表示に対応しました
Expand Down
55 changes: 55 additions & 0 deletions OpenTween.Tests/Api/Misskey/MeRequestTest.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 System;
using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class MeRequestTest
{
[Fact]
public async Task Send_Test()
{
var response = TestUtils.CreateApiResponse(new MisskeyUser());

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.SendAsync(It.IsAny<IHttpRequest>())
)
.Callback<IHttpRequest>(x =>
{
var request = Assert.IsType<PostRequest>(x);
Assert.Equal(new("i", UriKind.Relative), request.RequestUri);
Assert.Null(request.Query);
})
.ReturnsAsync(response);

var request = new MeRequest();
await request.Send(mock.Object);

mock.VerifyAll();
}
}
}
58 changes: 58 additions & 0 deletions OpenTween.Tests/Api/Misskey/MiauthCheckRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class MiauthCheckRequestTest
{
[Fact]
public async Task Send_Test()
{
var response = TestUtils.CreateApiResponse(new MiauthTokenResponse());

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.SendAsync(It.IsAny<IHttpRequest>())
)
.Callback<IHttpRequest>(x =>
{
var request = Assert.IsType<PostRequest>(x);
Assert.Equal(new("miauth/abc123/check", UriKind.Relative), request.RequestUri);
Assert.Null(request.Query);
})
.ReturnsAsync(response);

var request = new MiauthCheckRequest
{
SessionNonce = "abc123",
};
await request.Send(mock.Object);

mock.VerifyAll();
}
}
}
63 changes: 63 additions & 0 deletions OpenTween.Tests/Api/Misskey/NoteCreateRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class NoteCreateRequestTest
{
[Fact]
public async Task Send_Test()
{
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(
"""{"replyId":"aaaaa","text":"tetete","visibility":"public"}""",
request.JsonString
);
})
.ReturnsAsync(response);

var request = new NoteCreateRequest
{
Text = "tetete",
Visibility = "public",
ReplyId = new("aaaaa"),
};
await request.Send(mock.Object);

mock.VerifyAll();
}
}
}
58 changes: 58 additions & 0 deletions OpenTween.Tests/Api/Misskey/NoteDeleteRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class NoteDeleteRequestTest
{
[Fact]
public async Task Send_Test()
{
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/delete", UriKind.Relative), request.RequestUri);
Assert.Equal(
"""{"noteId":"aaaaa"}""",
request.JsonString
);
});

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

mock.VerifyAll();
}
}
}
59 changes: 59 additions & 0 deletions OpenTween.Tests/Api/Misskey/NoteReactionCreateRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class NoteReactionCreateRequestTest
{
[Fact]
public async Task Send_Test()
{
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/reactions/create", UriKind.Relative), request.RequestUri);
Assert.Equal(
"""{"noteId":"aaaaa","reaction":"❤"}""",
request.JsonString
);
});

var request = new NoteReactionCreateRequest
{
NoteId = new("aaaaa"),
Reaction = "❤",
};
await request.Send(mock.Object);

mock.VerifyAll();
}
}
}
58 changes: 58 additions & 0 deletions OpenTween.Tests/Api/Misskey/NoteReactionDeleteRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.Misskey
{
public class NoteReactionDeleteRequestTest
{
[Fact]
public async Task Send_Test()
{
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/reactions/delete", UriKind.Relative), request.RequestUri);
Assert.Equal(
"""{"noteId":"aaaaa"}""",
request.JsonString
);
});

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

mock.VerifyAll();
}
}
}
Loading

0 comments on commit 8132f06

Please sign in to comment.