Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![CircleCI branch](https://img.shields.io/circleci/project/github/OrionDevelop/Disboard.svg?style=flat-square)](https://circleci.com/gh/OrionDevelop/Disboard/tree/develop)


Collection of fediverse API wrapper libraries for .NET Standard 2.0.
Collection of fediverse fully-typed client API wrapper libraries for .NET Standard 2.0.


## Projects
Expand All @@ -14,7 +14,7 @@ Collection of fediverse API wrapper libraries for .NET Standard 2.0.
| -------- | ----------- | ----------------------------------------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| N/A | N/A | [`Disboard`](Source/Disboard) | `Disboard` | [![Disboard](https://img.shields.io/nuget/v/Disboard.svg?style=flat-square)](https://nuget.org/packages/Disboard) |
| Mastodon | 2.7.x | [`Disboard.Mastodon`](Source/Disboard.Mastodon) | `Disboard.Mastodon` | [![Disboard.Mastodon](https://img.shields.io/nuget/v/Disboard.Mastodon.svg?style=flat-square)](https://nuget.org/packages/Disboard.Mastodon) |
| Misskey | 10.90.0 | [`Disboard.Misskey`](Source/Disboard.Misskey) | `Disboard.Misskey` | [![Disboard.Misskey](https://img.shields.io/nuget/v/Disboard.Misskey.svg?style=flat-square)](https://nuget.org/packages/Disboard.Misskey) |
| Misskey | 11.23.x | [`Disboard.Misskey`](Source/Disboard.Misskey) | `Disboard.Misskey` | [![Disboard.Misskey](https://img.shields.io/nuget/v/Disboard.Misskey.svg?style=flat-square)](https://nuget.org/packages/Disboard.Misskey) |
| Pleroma | `ad318189` | [`Disboard.Pleroma`](Source/Disboard.Pleroma) | `Disboard.Pleroma` | [![Disboard.Pleroma](https://img.shields.io/nuget/v/Disboard.Pleroma.svg?style=flat-square)](https://nuget.org/packages/Disboard.Pleroma) |


Expand Down
4 changes: 2 additions & 2 deletions Source/Disboard.Misskey/Clients/HashtagsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<List<TrendTag>> TrendAsync()
return await PostAsync<List<TrendTag>>("/trend").Stay();
}

public async Task<List<User>> UsersAsync(string tag, string sort, int? limit = null, string state = null, string origin = null)
public async Task<IEnumerable<User>> UsersAsync(string tag, string sort, int? limit = null, string state = null, string origin = null)
{
var parameters = new List<KeyValuePair<string, object>>
{
Expand All @@ -46,7 +46,7 @@ public async Task<List<User>> UsersAsync(string tag, string sort, int? limit = n
parameters.AddIfValidValue("state", state);
parameters.AddIfValidValue("origin", origin);

return await PostAsync<List<User>>("/users", parameters).Stay();
return await PostAsync<IEnumerable<User>>("/users", parameters).Stay();
}
}
}
18 changes: 8 additions & 10 deletions Source/Disboard.Misskey/Clients/UsersClient.Ws.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,28 @@ namespace Disboard.Misskey.Clients
{
public partial class UsersClient
{
public async Task<UserWithCursor> FollowersWsAsync(string userId = null, string username = null, bool? iknow = null, int? limit = null, string cursor = null, string host = null)
public async Task<IEnumerable<FollowerRelation>> FollowersWsAsync(string userId = null, string username = null, int? limit = null, string sinceId = null, string untilId = null)
{
var parameters = new List<KeyValuePair<string, object>>();
parameters.AddIfValidValue("userId", userId);
parameters.AddIfValidValue("username", username);
parameters.AddIfValidValue("iknow", iknow);
parameters.AddIfValidValue("sinceId", sinceId);
parameters.AddIfValidValue("untilId", untilId);
parameters.AddIfValidValue("limit", limit);
parameters.AddIfValidValue("cursor", cursor);
parameters.AddIfValidValue("host", host);

return await SendWsAsync<UserWithCursor>("/followers", parameters).Stay();
return await SendWsAsync<IEnumerable<FollowerRelation>>("/followers", parameters).Stay();
}

public async Task<UserWithCursor> FollowingWsAsync(string userId, string username = null, bool? iknow = null, int? limit = null, string cursor = null, string host = null)
public async Task<IEnumerable<FollowingRelation>> FollowingWsAsync(string userId = null, string username = null, int? limit = null, string sinceId = null, string untilId = null)
{
var parameters = new List<KeyValuePair<string, object>>();
parameters.AddIfValidValue("userId", userId);
parameters.AddIfValidValue("username", username);
parameters.AddIfValidValue("iknow", iknow);
parameters.AddIfValidValue("sinceId", sinceId);
parameters.AddIfValidValue("untilId", untilId);
parameters.AddIfValidValue("limit", limit);
parameters.AddIfValidValue("cursor", cursor);
parameters.AddIfValidValue("host", host);

return await SendWsAsync<UserWithCursor>("/following", parameters).Stay();
return await SendWsAsync<IEnumerable<FollowingRelation>>("/following", parameters).Stay();
}

public async Task<List<FrequentlyRepliedUser>> GetFrequentlyRepliedUsersWsAsync(string userId, int? limit = null)
Expand Down
18 changes: 8 additions & 10 deletions Source/Disboard.Misskey/Clients/UsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,28 @@ protected internal UsersClient(MisskeyClient client) : base(client, "users")
Lists = new ListsClient(client);
}

public async Task<UserWithCursor> FollowersAsync(string userId = null, string username = null, bool? iknow = null, int? limit = null, string cursor = null, string host = null)
public async Task<IEnumerable<FollowerRelation>> FollowersAsync(string userId = null, string username = null, int? limit = null, string sinceId = null, string untilId = null)
{
var parameters = new List<KeyValuePair<string, object>>();
parameters.AddIfValidValue("userId", userId);
parameters.AddIfValidValue("username", username);
parameters.AddIfValidValue("iknow", iknow);
parameters.AddIfValidValue("sinceId", sinceId);
parameters.AddIfValidValue("untilId", untilId);
parameters.AddIfValidValue("limit", limit);
parameters.AddIfValidValue("cursor", cursor);
parameters.AddIfValidValue("host", host);

return await PostAsync<UserWithCursor>("/followers", parameters).Stay();
return await PostAsync<IEnumerable<FollowerRelation>>("/followers", parameters).Stay();
}

public async Task<UserWithCursor> FollowingAsync(string userId, string username = null, bool? iknow = null, int? limit = null, string cursor = null, string host = null)
public async Task<IEnumerable<FollowingRelation>> FollowingAsync(string userId = null, string username = null, int? limit = null, string sinceId = null, string untilId = null)
{
var parameters = new List<KeyValuePair<string, object>>();
parameters.AddIfValidValue("userId", userId);
parameters.AddIfValidValue("username", username);
parameters.AddIfValidValue("iknow", iknow);
parameters.AddIfValidValue("sinceId", sinceId);
parameters.AddIfValidValue("untilId", untilId);
parameters.AddIfValidValue("limit", limit);
parameters.AddIfValidValue("cursor", cursor);
parameters.AddIfValidValue("host", host);

return await PostAsync<UserWithCursor>("/following", parameters).Stay();
return await PostAsync<IEnumerable<FollowingRelation>>("/following", parameters).Stay();
}

public async Task<List<FrequentlyRepliedUser>> GetFrequentlyRepliedUsersAsync(string userId, int? limit = null)
Expand Down
51 changes: 34 additions & 17 deletions Source/Disboard.Misskey/Enums/Permission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,54 @@
{
public enum Permission
{
AccountRead = 0,
AccountRead = 1 << 0,

AccountWrite = 1,
AccountWrite = 1 << 1,

DriveRead = 1 << 1,
BlocksRead = 1 << 2,

DriveWrite = 1 << 2,
BlocksWrite = 1 << 3,

FavoritesRead = 1 << 3,
DriveRead = 1 << 4,

FavoriteWrite = 1 << 4,
DriveWrite = 1 << 5,

FollowingRead = 1 << 5,
FavoritesRead = 1 << 6,

FollowingWrite = 1 << 6,
FavoritesWrite = 1 << 7,

MessagingRead = 1 << 7,
FollowingRead = 1 << 8,

MessagingWrite = 1 << 8,
FollowingWrite = 1 << 9,

NoteWrite = 1 << 9,
MessagingRead = 1 << 10,

NotificationWrite = 1 << 10,
MessagingWrite = 1 << 11,

ReactionWrite = 1 << 11,
MutesRead = 1 << 12,

VoteWrite = 1 << 12,
MutesWrite = 1 << 13,

// old?
AccountRead2 = 1 << 13,
NotificationsRead = 1 << 14,

AccountWrite2 = 1 << 14
NotificationsWrite = 1 << 15,

ReactionsRead = 1 << 16,

ReactionsWrite = 1 << 17,

VotesWrite = 1 << 18,

PagesRead = 1 << 19,

PagesWrite = 1 << 20,

PageLikesRead = 1 << 21,

PageLikesWrite = 1 << 22,

UserGroupsRead = 1 << 23,

UserGroupsWrite = 1 << 24
}
}
77 changes: 52 additions & 25 deletions Source/Disboard.Misskey/Extensions/PermissionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,79 @@ public static string ToStr(this Permission permission)
switch (permission)
{
case Permission.AccountRead:
return "account-read";
return "read:account";

case Permission.AccountWrite:
return "account-write";
return "write:account";

case Permission.BlocksRead:
return "read:blocks";

case Permission.BlocksWrite:
return "write:blocks";

case Permission.DriveRead:
return "drive-read";
return "read:drive";

case Permission.DriveWrite:
return "drive-write";
return "write:drive";

case Permission.FavoritesRead:
return "favorites-read";
return "read:favorites";

case Permission.FavoriteWrite:
return "favorite-write";

case Permission.FollowingWrite:
return "following-write";
case Permission.FavoritesWrite:
return "write:favorites";

case Permission.FollowingRead:
return "following-read";
return "read:following";

case Permission.FollowingWrite:
return "write:following";

case Permission.MessagingRead:
return "messaging-read";
return "read:messaging";

case Permission.MessagingWrite:
return "messaging-write";
return "write:messaging";

case Permission.MutesRead:
return "read:mutes";

case Permission.MutesWrite:
return "write:mutes";

case Permission.NotificationsRead:
return "read:notifications";

case Permission.NotificationsWrite:
return "write:notification";

case Permission.ReactionsRead:
return "read:reactions";

case Permission.ReactionsWrite:
return "write:reactions";

case Permission.VotesWrite:
return "write:votes";

case Permission.NoteWrite:
return "note-write";
case Permission.PagesRead:
return "read:pages";

case Permission.NotificationWrite:
return "notification-write";
case Permission.PagesWrite:
return "write:pages";

case Permission.ReactionWrite:
return "reaction-write";
case Permission.PageLikesRead:
return "read:page-likes";

case Permission.VoteWrite:
return "vote-write";
case Permission.PageLikesWrite:
return "write:page-likes";

case Permission.AccountRead2:
return "account/read";
case Permission.UserGroupsRead:
return "read:user-groups";

case Permission.AccountWrite2:
return "account/write";
case Permission.UserGroupsWrite:
return "write:user-groups";

default:
throw new ArgumentOutOfRangeException(nameof(permission), permission, null);
Expand Down
34 changes: 23 additions & 11 deletions Source/Disboard.Misskey/MisskeyClient.Api.Ws.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,32 @@ namespace Disboard.Misskey
{
public partial class MisskeyClient
{
public async Task<Chart> ChartWsAsync(int? limit = null)
public async Task<Endpoint> EndpointWsAsync(string endpoint)
{
var parameters = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("endpoint", endpoint)
};

return await SendWsAsync<Endpoint>("endpoint", parameters).Stay();
}

public async Task<IEnumerable<string>> EndpointsWsAsync()
{
return await SendWsAsync<IEnumerable<string>>("endpoints").Stay();
}

public async Task<Metadata> MetaWsAsync(bool? detail = null)
{
var parameters = new List<KeyValuePair<string, object>>();
parameters.AddIfValidValue("limit", limit);
parameters.AddIfValidValue("detail", detail);

return await SendWsAsync<Metadata>("meta", parameters).Stay();
}

return await SendWsAsync<Chart>("chart").Stay();
public async Task<IEnumerable<User>> PinnedUsersWsAsync()
{
return await SendWsAsync<IEnumerable<User>>("pinned-users").Stay();
}

public async Task<Drive> DriveWsAsync()
Expand All @@ -27,14 +47,6 @@ public async Task<User> IWsAsync()
return await SendWsAsync<User>("i").Stay();
}

public async Task<Metadata> MetaWsAsync(bool? detail = null)
{
var parameters = new List<KeyValuePair<string, object>>();
parameters.AddIfValidValue("detail", detail);

return await SendWsAsync<Metadata>("meta", parameters).Stay();
}

public async Task<List<Note>> NotesWsAsync(bool? local = null, bool? reply = null, bool? renote = null, bool? withFiles = null, bool? poll = null, int? limit = null, string sinceId = null, string untilId = null)
{
var parameters = new List<KeyValuePair<string, object>>();
Expand Down
Loading