1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-28 13:58:51 +00:00
comunicmobile/lib/models/server_config.dart

108 lines
3.6 KiB
Dart

import 'package:flutter/widgets.dart';
import 'package:version/version.dart';
/// Server static configuration
///
/// @author Pierre Hubert
class PasswordPolicy {
final bool allowMailInPassword;
final bool allowNameInPassword;
final int minPasswordLength;
final int minNumberUpperCaseLetters;
final int minNumberLowerCaseLetters;
final int minNumberDigits;
final int minNumberSpecialCharacters;
final int minCategoriesPresence;
const PasswordPolicy({
@required this.allowMailInPassword,
@required this.allowNameInPassword,
@required this.minPasswordLength,
@required this.minNumberUpperCaseLetters,
@required this.minNumberLowerCaseLetters,
@required this.minNumberDigits,
@required this.minNumberSpecialCharacters,
@required this.minCategoriesPresence,
}) : assert(allowMailInPassword != null),
assert(allowNameInPassword != null),
assert(minPasswordLength != null),
assert(minNumberUpperCaseLetters != null),
assert(minNumberLowerCaseLetters != null),
assert(minNumberDigits != null),
assert(minNumberSpecialCharacters != null),
assert(minCategoriesPresence != null);
}
class ServerDataConservationPolicy {
final int minInactiveAccountLifetime;
final int minNotificationLifetime;
final int minCommentsLifetime;
final int minPostsLifetime;
final int minConversationMessagesLifetime;
final int minLikesLifetime;
const ServerDataConservationPolicy({
@required this.minInactiveAccountLifetime,
@required this.minNotificationLifetime,
@required this.minCommentsLifetime,
@required this.minPostsLifetime,
@required this.minConversationMessagesLifetime,
@required this.minLikesLifetime,
}) : assert(minInactiveAccountLifetime != null),
assert(minNotificationLifetime != null),
assert(minCommentsLifetime != null),
assert(minPostsLifetime != null),
assert(minConversationMessagesLifetime != null),
assert(minLikesLifetime != null);
}
class ConversationsPolicy {
final int minMessageLen;
final int maxMessageLen;
final List<String> allowedFilesType;
final int filesMaxSize;
final int writingEventInterval;
final int writingEventLifetime;
const ConversationsPolicy({
@required this.minMessageLen,
@required this.maxMessageLen,
@required this.allowedFilesType,
@required this.filesMaxSize,
@required this.writingEventInterval,
@required this.writingEventLifetime,
}) : assert(minMessageLen != null),
assert(maxMessageLen != null),
assert(allowedFilesType != null),
assert(filesMaxSize != null),
assert(writingEventInterval != null),
assert(writingEventLifetime != null);
}
class ServerConfig {
final Version minSupportedMobileVersion;
final String termsURL;
final String playStoreURL;
final String androidDirectDownloadURL;
final PasswordPolicy passwordPolicy;
final ServerDataConservationPolicy dataConservationPolicy;
final ConversationsPolicy conversationsPolicy;
const ServerConfig({
@required this.minSupportedMobileVersion,
@required this.termsURL,
@required this.playStoreURL,
@required this.androidDirectDownloadURL,
@required this.passwordPolicy,
@required this.dataConservationPolicy,
@required this.conversationsPolicy,
}) : assert(minSupportedMobileVersion != null),
assert(termsURL != null),
assert(playStoreURL != null),
assert(androidDirectDownloadURL != null),
assert(passwordPolicy != null),
assert(dataConservationPolicy != null),
assert(conversationsPolicy != null);
}