sharp-chat/SharpChat/ChannelInfo.cs

36 lines
981 B
C#
Raw Normal View History

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