mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-28 13:58:51 +00:00
74 lines
2.0 KiB
Dart
74 lines
2.0 KiB
Dart
import 'package:meta/meta.dart';
|
|
|
|
/// Group information
|
|
///
|
|
/// @author Pierre HUBERT
|
|
|
|
enum GroupMembershipLevel {
|
|
ADMINISTRATOR,
|
|
MODERATOR,
|
|
MEMBER,
|
|
INVITED,
|
|
PENDING,
|
|
VISITOR
|
|
}
|
|
|
|
enum GroupVisibilityLevel { OPEN, PRIVATE, SECRETE }
|
|
|
|
enum GroupRegistrationLevel { OPEN, MODERATED, CLOSED }
|
|
|
|
enum GroupPostCreationLevel { MODERATORS, MEMBERS }
|
|
|
|
class Group {
|
|
final int id;
|
|
String name;
|
|
final String iconURL;
|
|
final int numberMembers;
|
|
GroupMembershipLevel membershipLevel;
|
|
GroupVisibilityLevel visibilityLevel;
|
|
GroupRegistrationLevel registrationLevel;
|
|
GroupPostCreationLevel postCreationLevel;
|
|
String virtualDirectory;
|
|
bool following;
|
|
|
|
Group({
|
|
@required this.id,
|
|
@required this.name,
|
|
@required this.iconURL,
|
|
@required this.numberMembers,
|
|
@required this.membershipLevel,
|
|
@required this.visibilityLevel,
|
|
@required this.registrationLevel,
|
|
@required this.postCreationLevel,
|
|
@required this.virtualDirectory,
|
|
@required this.following,
|
|
}) : assert(id != null),
|
|
assert(name != null),
|
|
assert(iconURL != null),
|
|
assert(numberMembers != null),
|
|
assert(membershipLevel != null),
|
|
assert(visibilityLevel != null),
|
|
assert(registrationLevel != null),
|
|
assert(postCreationLevel != null),
|
|
assert(following != null);
|
|
|
|
get displayName => this.name;
|
|
|
|
bool get isAtLeastMember =>
|
|
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
|
|
membershipLevel == GroupMembershipLevel.MODERATOR ||
|
|
membershipLevel == GroupMembershipLevel.MEMBER;
|
|
|
|
bool get isAdmin => membershipLevel == GroupMembershipLevel.ADMINISTRATOR;
|
|
|
|
bool get isAtLeastModerator =>
|
|
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
|
|
membershipLevel == GroupMembershipLevel.MODERATOR;
|
|
|
|
bool get canCreatePost =>
|
|
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
|
|
membershipLevel == GroupMembershipLevel.MODERATOR ||
|
|
(membershipLevel == GroupMembershipLevel.MEMBER &&
|
|
postCreationLevel == GroupPostCreationLevel.MEMBERS);
|
|
}
|