1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-23 05:19:22 +00:00
comunicmobile/lib/models/server_config.dart

129 lines
4.3 KiB
Dart
Raw Normal View History

import 'package:flutter/widgets.dart';
2021-02-20 08:24:51 +00:00
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);
}
2021-03-12 15:19:07 +00:00
class ConversationsPolicy {
2021-04-06 15:04:55 +00:00
final int maxConversationNameLen;
2021-03-12 15:19:07 +00:00
final int minMessageLen;
final int maxMessageLen;
final List<String> allowedFilesType;
final int filesMaxSize;
final int writingEventInterval;
final int writingEventLifetime;
2021-03-12 18:36:42 +00:00
final int maxMessageImageWidth;
final int maxMessageImageHeight;
final int maxThumbnailWidth;
final int maxThumbnailHeight;
2021-03-13 10:33:25 +00:00
final int maxLogoWidth;
final int maxLogoHeight;
2021-03-12 15:19:07 +00:00
const ConversationsPolicy({
2021-04-06 15:04:55 +00:00
@required this.maxConversationNameLen,
2021-03-12 15:19:07 +00:00
@required this.minMessageLen,
@required this.maxMessageLen,
@required this.allowedFilesType,
@required this.filesMaxSize,
@required this.writingEventInterval,
@required this.writingEventLifetime,
2021-03-12 18:36:42 +00:00
@required this.maxMessageImageWidth,
@required this.maxMessageImageHeight,
@required this.maxThumbnailWidth,
@required this.maxThumbnailHeight,
2021-03-13 10:33:25 +00:00
@required this.maxLogoWidth,
@required this.maxLogoHeight,
2021-04-06 15:04:55 +00:00
}) : assert(maxConversationNameLen != null),
assert(minMessageLen != null),
2021-03-12 15:19:07 +00:00
assert(maxMessageLen != null),
assert(allowedFilesType != null),
assert(filesMaxSize != null),
assert(writingEventInterval != null),
2021-03-12 18:36:42 +00:00
assert(writingEventLifetime != null),
assert(maxMessageImageWidth != null),
assert(maxMessageImageHeight != null),
assert(maxThumbnailWidth != null),
2021-03-13 10:33:25 +00:00
assert(maxThumbnailHeight != null),
assert(maxLogoWidth != null),
assert(maxLogoHeight != null);
2021-03-12 15:19:07 +00:00
}
class ServerConfig {
2021-02-20 08:24:51 +00:00
final Version minSupportedMobileVersion;
final String termsURL;
final String playStoreURL;
final String androidDirectDownloadURL;
final PasswordPolicy passwordPolicy;
final ServerDataConservationPolicy dataConservationPolicy;
2021-03-12 15:19:07 +00:00
final ConversationsPolicy conversationsPolicy;
const ServerConfig({
2021-02-20 08:24:51 +00:00
@required this.minSupportedMobileVersion,
@required this.termsURL,
@required this.playStoreURL,
@required this.androidDirectDownloadURL,
@required this.passwordPolicy,
@required this.dataConservationPolicy,
2021-03-12 15:19:07 +00:00
@required this.conversationsPolicy,
2021-02-20 08:24:51 +00:00
}) : assert(minSupportedMobileVersion != null),
assert(termsURL != null),
assert(playStoreURL != null),
assert(androidDirectDownloadURL != null),
2021-02-20 08:24:51 +00:00
assert(passwordPolicy != null),
2021-03-12 15:19:07 +00:00
assert(dataConservationPolicy != null),
assert(conversationsPolicy != null);
}