forked from LittleBigRefresh/Refresh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameUser.cs
More file actions
165 lines (131 loc) · 5.53 KB
/
Copy pathGameUser.cs
File metadata and controls
165 lines (131 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System.Xml.Serialization;
using MongoDB.Bson;
using Bunkum.Core.RateLimit;
using Refresh.Database.Models.Playlists;
namespace Refresh.Database.Models.Users;
[JsonObject(MemberSerialization.OptIn)]
public partial class GameUser : IRealmObject, IRateLimitUser
{
[PrimaryKey] public ObjectId UserId { get; set; } = ObjectId.GenerateNewId();
[Indexed] public string Username { get; set; } = string.Empty;
[Indexed] public string? EmailAddress { get; set; }
[Indexed] public string? PasswordBcrypt { get; set; } = null;
public bool EmailAddressVerified { get; set; }
public bool ShouldResetPassword { get; set; }
public string IconHash { get; set; } = "0";
/// <summary>
/// The force match of the user, cleared on login
/// </summary>
public ObjectId? ForceMatch { get; set; }
/// <summary>
/// The <see cref="IconHash"/>, except only for PSP clients.
/// </summary>
/// <remarks>
/// PSP doesn't support remote assets, and instead only uses it's own GUID icon hashes, which cant be loaded by other clients.
/// Hopefully this explains why this distinction is necessary.
/// </remarks>
public string PspIconHash { get; set; } = "0";
/// <summary>
/// The <see cref="IconHash"/>, except only for Vita clients.
/// </summary>
/// <remarks>
/// Vita GUIDs do not map to mainline GUIDs, so we dont want someone to set their Vita icon, and it map to an invalid GUID on PS3.
/// </remarks>
public string VitaIconHash { get; set; } = "0";
/// <summary>
/// The <see cref="IconHash"/>, except only for clients in beta mode.
/// </summary>
public string BetaIconHash { get; set; } = "0";
/// <summary>
/// The cumulative size of all the assets the user has uploaded
/// </summary>
public int FilesizeQuotaUsage { get; set; }
#region Timed Level Limit
/// <summary>
/// How many levels the user published/overwrote during the configured timed level limit,
/// if enabled.
/// </summary>
public int TimedLevelUploads { get; set; }
/// <summary>
/// The timestamp when this user's timed level limit will reset.
/// When that happens, set this property to null and reset TimedLevelUploads to 0.
/// </summary>
public DateTimeOffset? TimedLevelUploadExpiryDate { get; set; }
#endregion
public string Description { get; set; } = "";
public int LocationX { get; set; }
public int LocationY { get; set; }
public DateTimeOffset JoinDate { get; set; }
public string BetaPlanetsHash { get; set; } = "0";
public string Lbp2PlanetsHash { get; set; } = "0";
public string Lbp3PlanetsHash { get; set; } = "0";
public string VitaPlanetsHash { get; set; } = "0";
public string YayFaceHash { get; set; } = "0";
public string BooFaceHash { get; set; } = "0";
public string MehFaceHash { get; set; } = "0";
public bool AllowIpAuthentication { get; set; }
public string? BanReason { get; set; }
public DateTimeOffset? BanExpiryDate { get; set; }
public DateTimeOffset LastLoginDate { get; set; }
public bool RpcnAuthenticationAllowed { get; set; }
public bool PsnAuthenticationAllowed { get; set; }
private int _ProfileVisibility { get; set; } = (int)Visibility.All;
private int _LevelVisibility { get; set; } = (int)Visibility.All;
/// <summary>
/// The auth token the presence server knows this user by, null if not connected to the presence server
/// </summary>
public string? PresenceServerAuthToken { get; set; }
/// <summary>
/// The user's root playlist. This playlist contains all the user's playlists, and optionally other slots as well,
/// although the game does not expose the ability to do this normally.
/// </summary>
public GamePlaylist? RootPlaylist { get; set; }
/// <summary>
/// Whether the user's profile information is exposed in the public API.
/// </summary>
[Ignored]
public Visibility ProfileVisibility
{
get => (Visibility)this._ProfileVisibility;
set => this._ProfileVisibility = (int)value;
}
/// <summary>
/// Whether the user's levels are exposed in the public API.
/// </summary>
[Ignored]
public Visibility LevelVisibility
{
get => (Visibility)this._LevelVisibility;
set => this._LevelVisibility = (int)value;
}
/// <summary>
/// If `true`, unescape XML tags sent to /filter
/// </summary>
public bool UnescapeXmlSequences { get; set; }
[Ignored] public GameUserRole Role
{
get => (GameUserRole)this._Role;
set => this._Role = (byte)value;
}
/// <summary>
/// Whether modded content should be shown in level listings
/// </summary>
public bool ShowModdedContent { get; set; } = true;
/// <summary>
/// Whether reuploaded content should be shown in level listings
/// </summary>
public bool ShowReuploadedContent { get; set; } = true;
// ReSharper disable once InconsistentNaming
internal byte _Role { get; set; }
public override string ToString() => $"{this.Username} ({this.Role})";
#region Rate-limiting
public bool RateLimitUserIdIsEqual(object obj)
{
if (obj is not ObjectId id) return false;
return this.UserId.Equals(id);
}
// Defined in authentication provider. Avoids Realm threading nonsense.
[Ignored] [XmlIgnore] public object RateLimitUserId { get; set; } = null!;
#endregion
[Ignored] public bool FakeUser { get; set; } = false;
}