sharp-chat/SharpChat/ChannelInfo.cs

35 lines
981 B
C#

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; }
public bool HasPassword
=> !string.IsNullOrWhiteSpace(Password);
public bool IsPublic
=> !IsTemporary && Rank < 1 && !HasPassword;
public ChannelInfo(
string name,
string? password = null,
bool isTemporary = false,
int rank = 0,
long ownerId = 0
) {
Name = name;
Password = password ?? string.Empty;
IsTemporary = isTemporary;
Rank = rank;
OwnerId = ownerId;
}
public bool IsOwner(UserInfo user) {
return OwnerId > 0
&& user != null
&& OwnerId == user.UserId;
}
}
}