mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Rename User
to APIUser
and move to correct namespace
This commit is contained in:
@ -3,17 +3,17 @@
|
||||
|
||||
using System.Net.Http;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class CreateNewPrivateMessageRequest : APIRequest<CreateNewPrivateMessageResponse>
|
||||
{
|
||||
private readonly User user;
|
||||
private readonly APIUser user;
|
||||
private readonly Message message;
|
||||
|
||||
public CreateNewPrivateMessageRequest(User user, Message message)
|
||||
public CreateNewPrivateMessageRequest(APIUser user, Message message)
|
||||
{
|
||||
this.user = user;
|
||||
this.message = message;
|
||||
|
@ -2,11 +2,11 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetFriendsRequest : APIRequest<List<User>>
|
||||
public class GetFriendsRequest : APIRequest<List<APIUser>>
|
||||
{
|
||||
protected override string Target => @"friends";
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserRequest : APIRequest<User>
|
||||
public class GetUserRequest : APIRequest<APIUser>
|
||||
{
|
||||
public readonly string Lookup;
|
||||
public readonly RulesetInfo Ruleset;
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUsersResponse : ResponseWithCursor
|
||||
{
|
||||
[JsonProperty("users")]
|
||||
public List<User> Users;
|
||||
public List<APIUser> Users;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Users;
|
||||
|
||||
#nullable enable
|
||||
|
||||
@ -72,10 +71,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty("artist_unicode")]
|
||||
public string ArtistUnicode { get; set; } = string.Empty;
|
||||
|
||||
public User? Author = new User();
|
||||
public APIUser? Author = new APIUser();
|
||||
|
||||
/// <summary>
|
||||
/// Helper property to deserialize a username to <see cref="User"/>.
|
||||
/// Helper property to deserialize a username to <see cref="APIUser"/>.
|
||||
/// </summary>
|
||||
[JsonProperty(@"user_id")]
|
||||
public int AuthorID
|
||||
@ -83,13 +82,13 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
get => Author?.Id ?? 1;
|
||||
set
|
||||
{
|
||||
Author ??= new User();
|
||||
Author ??= new APIUser();
|
||||
Author.Id = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper property to deserialize a username to <see cref="User"/>.
|
||||
/// Helper property to deserialize a username to <see cref="APIUser"/>.
|
||||
/// </summary>
|
||||
[JsonProperty(@"creator")]
|
||||
public string AuthorString
|
||||
@ -97,7 +96,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
get => Author?.Username ?? string.Empty;
|
||||
set
|
||||
{
|
||||
Author ??= new User();
|
||||
Author ??= new APIUser();
|
||||
Author.Username = value;
|
||||
}
|
||||
}
|
||||
|
22
osu.Game/Online/API/Requests/Responses/APIPlayStyle.cs
Normal file
22
osu.Game/Online/API/Requests/Responses/APIPlayStyle.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public enum APIPlayStyle
|
||||
{
|
||||
[Description("Keyboard")]
|
||||
Keyboard,
|
||||
|
||||
[Description("Mouse")]
|
||||
Mouse,
|
||||
|
||||
[Description("Tablet")]
|
||||
Tablet,
|
||||
|
||||
[Description("Touch Screen")]
|
||||
Touch,
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
@ -25,7 +24,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public int MaxCombo { get; set; }
|
||||
|
||||
[JsonProperty(@"user")]
|
||||
public User User { get; set; }
|
||||
public APIUser User { get; set; }
|
||||
|
||||
[JsonProperty(@"id")]
|
||||
public long OnlineID { get; set; }
|
||||
|
@ -1,14 +1,263 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIUser
|
||||
public class APIUser : IEquatable<APIUser>, IUser
|
||||
{
|
||||
[JsonProperty(@"id")]
|
||||
public int Id { get; set; } = 1;
|
||||
|
||||
[JsonProperty(@"join_date")]
|
||||
public DateTimeOffset JoinDate;
|
||||
|
||||
[JsonProperty(@"username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[JsonProperty(@"previous_usernames")]
|
||||
public string[] PreviousUsernames;
|
||||
|
||||
[JsonProperty(@"country")]
|
||||
public Country Country;
|
||||
|
||||
public readonly Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
||||
|
||||
public readonly Bindable<UserActivity> Activity = new Bindable<UserActivity>();
|
||||
|
||||
[JsonProperty(@"profile_colour")]
|
||||
public string Colour;
|
||||
|
||||
[JsonProperty(@"avatar_url")]
|
||||
public string AvatarUrl;
|
||||
|
||||
[JsonProperty(@"cover_url")]
|
||||
public string CoverUrl
|
||||
{
|
||||
get => Cover?.Url;
|
||||
set => Cover = new UserCover { Url = value };
|
||||
}
|
||||
|
||||
[JsonProperty(@"cover")]
|
||||
public UserCover Cover;
|
||||
|
||||
public class UserCover
|
||||
{
|
||||
[JsonProperty(@"custom_url")]
|
||||
public string CustomUrl;
|
||||
|
||||
[JsonProperty(@"url")]
|
||||
public string Url;
|
||||
|
||||
[JsonProperty(@"id")]
|
||||
public int? Id;
|
||||
}
|
||||
|
||||
[JsonProperty(@"is_admin")]
|
||||
public bool IsAdmin;
|
||||
|
||||
[JsonProperty(@"is_supporter")]
|
||||
public bool IsSupporter;
|
||||
|
||||
[JsonProperty(@"support_level")]
|
||||
public int SupportLevel;
|
||||
|
||||
[JsonProperty(@"is_gmt")]
|
||||
public bool IsGMT;
|
||||
|
||||
[JsonProperty(@"is_qat")]
|
||||
public bool IsQAT;
|
||||
|
||||
[JsonProperty(@"is_bng")]
|
||||
public bool IsBNG;
|
||||
|
||||
[JsonProperty(@"is_bot")]
|
||||
public bool IsBot;
|
||||
|
||||
[JsonProperty(@"is_active")]
|
||||
public bool Active;
|
||||
|
||||
[JsonProperty(@"is_online")]
|
||||
public bool IsOnline;
|
||||
|
||||
[JsonProperty(@"pm_friends_only")]
|
||||
public bool PMFriendsOnly;
|
||||
|
||||
[JsonProperty(@"interests")]
|
||||
public string Interests;
|
||||
|
||||
[JsonProperty(@"occupation")]
|
||||
public string Occupation;
|
||||
|
||||
[JsonProperty(@"title")]
|
||||
public string Title;
|
||||
|
||||
[JsonProperty(@"location")]
|
||||
public string Location;
|
||||
|
||||
[JsonProperty(@"last_visit")]
|
||||
public DateTimeOffset? LastVisit;
|
||||
|
||||
[JsonProperty(@"twitter")]
|
||||
public string Twitter;
|
||||
|
||||
[JsonProperty(@"discord")]
|
||||
public string Discord;
|
||||
|
||||
[JsonProperty(@"website")]
|
||||
public string Website;
|
||||
|
||||
[JsonProperty(@"post_count")]
|
||||
public int PostCount;
|
||||
|
||||
[JsonProperty(@"comments_count")]
|
||||
public int CommentsCount;
|
||||
|
||||
[JsonProperty(@"follower_count")]
|
||||
public int FollowerCount;
|
||||
|
||||
[JsonProperty(@"mapping_follower_count")]
|
||||
public int MappingFollowerCount;
|
||||
|
||||
[JsonProperty(@"favourite_beatmapset_count")]
|
||||
public int FavouriteBeatmapsetCount;
|
||||
|
||||
[JsonProperty(@"graveyard_beatmapset_count")]
|
||||
public int GraveyardBeatmapsetCount;
|
||||
|
||||
[JsonProperty(@"loved_beatmapset_count")]
|
||||
public int LovedBeatmapsetCount;
|
||||
|
||||
[JsonProperty(@"ranked_beatmapset_count")]
|
||||
public int RankedBeatmapsetCount;
|
||||
|
||||
[JsonProperty(@"pending_beatmapset_count")]
|
||||
public int PendingBeatmapsetCount;
|
||||
|
||||
[JsonProperty(@"scores_best_count")]
|
||||
public int ScoresBestCount;
|
||||
|
||||
[JsonProperty(@"scores_first_count")]
|
||||
public int ScoresFirstCount;
|
||||
|
||||
[JsonProperty(@"scores_recent_count")]
|
||||
public int ScoresRecentCount;
|
||||
|
||||
[JsonProperty(@"beatmap_playcounts_count")]
|
||||
public int BeatmapPlaycountsCount;
|
||||
|
||||
[JsonProperty]
|
||||
public User User;
|
||||
private string[] playstyle
|
||||
{
|
||||
set => PlayStyles = value?.Select(str => Enum.Parse(typeof(APIPlayStyle), str, true)).Cast<APIPlayStyle>().ToArray();
|
||||
}
|
||||
|
||||
public APIPlayStyle[] PlayStyles;
|
||||
|
||||
[JsonProperty(@"playmode")]
|
||||
public string PlayMode;
|
||||
|
||||
[JsonProperty(@"profile_order")]
|
||||
public string[] ProfileOrder;
|
||||
|
||||
[JsonProperty(@"kudosu")]
|
||||
public KudosuCount Kudosu;
|
||||
|
||||
public class KudosuCount
|
||||
{
|
||||
[JsonProperty(@"total")]
|
||||
public int Total;
|
||||
|
||||
[JsonProperty(@"available")]
|
||||
public int Available;
|
||||
}
|
||||
|
||||
private UserStatistics statistics;
|
||||
|
||||
/// <summary>
|
||||
/// User statistics for the requested ruleset (in the case of a <see cref="GetUserRequest"/> or <see cref="GetFriendsRequest"/> response).
|
||||
/// Otherwise empty.
|
||||
/// </summary>
|
||||
[JsonProperty(@"statistics")]
|
||||
public UserStatistics Statistics
|
||||
{
|
||||
get => statistics ??= new UserStatistics();
|
||||
set
|
||||
{
|
||||
if (statistics != null)
|
||||
// we may already have rank history populated
|
||||
value.RankHistory = statistics.RankHistory;
|
||||
|
||||
statistics = value;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(@"rank_history")]
|
||||
private RankHistoryData rankHistory
|
||||
{
|
||||
set => statistics.RankHistory = value;
|
||||
}
|
||||
|
||||
public class RankHistoryData
|
||||
{
|
||||
[JsonProperty(@"mode")]
|
||||
public string Mode;
|
||||
|
||||
[JsonProperty(@"data")]
|
||||
public int[] Data;
|
||||
}
|
||||
|
||||
[JsonProperty("badges")]
|
||||
public Badge[] Badges;
|
||||
|
||||
[JsonProperty("user_achievements")]
|
||||
public UserAchievement[] Achievements;
|
||||
|
||||
public class UserAchievement
|
||||
{
|
||||
[JsonProperty("achieved_at")]
|
||||
public DateTimeOffset AchievedAt;
|
||||
|
||||
[JsonProperty("achievement_id")]
|
||||
public int ID;
|
||||
}
|
||||
|
||||
[JsonProperty("monthly_playcounts")]
|
||||
public APIUserHistoryCount[] MonthlyPlaycounts;
|
||||
|
||||
[JsonProperty("replays_watched_counts")]
|
||||
public APIUserHistoryCount[] ReplaysWatchedCounts;
|
||||
|
||||
/// <summary>
|
||||
/// All user statistics per ruleset's short name (in the case of a <see cref="GetUsersRequest"/> response).
|
||||
/// Otherwise empty. Can be altered for testing purposes.
|
||||
/// </summary>
|
||||
// todo: this should likely be moved to a separate UserCompact class at some point.
|
||||
[JsonProperty("statistics_rulesets")]
|
||||
[CanBeNull]
|
||||
public Dictionary<string, UserStatistics> RulesetsStatistics { get; set; }
|
||||
|
||||
public override string ToString() => Username;
|
||||
|
||||
/// <summary>
|
||||
/// A user instance for displaying locally created system messages.
|
||||
/// </summary>
|
||||
public static readonly APIUser SYSTEM_USER = new APIUser
|
||||
{
|
||||
Id = 0,
|
||||
Username = "system",
|
||||
Colour = @"9c0101",
|
||||
};
|
||||
|
||||
public int OnlineID => Id;
|
||||
|
||||
public bool Equals(APIUser other) => OnlineID == other?.OnlineID;
|
||||
}
|
||||
}
|
||||
|
13
osu.Game/Online/API/Requests/Responses/APIUserContainer.cs
Normal file
13
osu.Game/Online/API/Requests/Responses/APIUserContainer.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIUserContainer
|
||||
{
|
||||
[JsonProperty]
|
||||
public APIUser User;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIUserHistoryCount
|
||||
{
|
||||
[JsonProperty("start_date")]
|
||||
public DateTime Date;
|
||||
|
||||
[JsonProperty("count")]
|
||||
public long Count;
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
@ -31,7 +30,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public long UserID { get; set; }
|
||||
|
||||
[JsonProperty("user")]
|
||||
public User User { get; set; }
|
||||
public APIUser User { get; set; }
|
||||
|
||||
[JsonProperty("position")]
|
||||
public int? Position { get; set; }
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Users;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
@ -20,7 +19,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"user_id")]
|
||||
public long? UserId { get; set; }
|
||||
|
||||
public User User { get; set; }
|
||||
public APIUser User { get; set; }
|
||||
|
||||
[JsonProperty(@"message")]
|
||||
public string Message { get; set; }
|
||||
@ -61,7 +60,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"pinned")]
|
||||
public bool Pinned { get; set; }
|
||||
|
||||
public User EditedUser { get; set; }
|
||||
public APIUser EditedUser { get; set; }
|
||||
|
||||
public bool IsTopLevel => !ParentId.HasValue;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Users;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@ -43,10 +42,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
}
|
||||
}
|
||||
|
||||
private List<User> users;
|
||||
private List<APIUser> users;
|
||||
|
||||
[JsonProperty(@"users")]
|
||||
public List<User> Users
|
||||
public List<APIUser> Users
|
||||
{
|
||||
get => users;
|
||||
set
|
||||
|
Reference in New Issue
Block a user