2024-05-19 21:02:17 +00:00
|
|
|
|
namespace SharpChat {
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public class ChannelInfo {
|
2023-02-22 00:28:53 +00:00
|
|
|
|
public string Name { get; }
|
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
public bool IsTemporary { get; set; }
|
|
|
|
|
public int Rank { get; set; }
|
|
|
|
|
public long OwnerId { get; set; }
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
|
|
|
|
public bool HasPassword
|
|
|
|
|
=> !string.IsNullOrWhiteSpace(Password);
|
|
|
|
|
|
2024-05-19 21:02:17 +00:00
|
|
|
|
public bool IsPublic
|
|
|
|
|
=> !IsTemporary && Rank < 1 && !HasPassword;
|
|
|
|
|
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public ChannelInfo(
|
2023-02-22 00:28:53 +00:00
|
|
|
|
string name,
|
2024-05-10 19:18:55 +00:00
|
|
|
|
string? password = null,
|
2023-02-22 00:28:53 +00:00
|
|
|
|
bool isTemporary = false,
|
|
|
|
|
int rank = 0,
|
|
|
|
|
long ownerId = 0
|
|
|
|
|
) {
|
2022-08-30 15:00:58 +00:00
|
|
|
|
Name = name;
|
2023-02-22 00:28:53 +00:00
|
|
|
|
Password = password ?? string.Empty;
|
|
|
|
|
IsTemporary = isTemporary;
|
|
|
|
|
Rank = rank;
|
|
|
|
|
OwnerId = ownerId;
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public bool IsOwner(UserInfo user) {
|
2023-02-22 00:28:53 +00:00
|
|
|
|
return OwnerId > 0
|
|
|
|
|
&& user != null
|
|
|
|
|
&& OwnerId == user.UserId;
|
|
|
|
|
}
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|