mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Updated conversations policy
This commit is contained in:
parent
a4181e3d42
commit
e02ab259b6
@ -19,38 +19,46 @@ class ServerConfigurationHelper {
|
||||
|
||||
final passwordPolicy = response["password_policy"];
|
||||
final dataConservationPolicy = response["data_conservation_policy"];
|
||||
final conversationsPolicy = response["conversations_policy"];
|
||||
|
||||
_config = ServerConfig(
|
||||
minSupportedMobileVersion:
|
||||
Version.parse(response["min_supported_mobile_version"]),
|
||||
termsURL: response["terms_url"],
|
||||
playStoreURL: response["play_store_url"],
|
||||
androidDirectDownloadURL: response["android_direct_download_url"],
|
||||
passwordPolicy: PasswordPolicy(
|
||||
allowMailInPassword: passwordPolicy["allow_email_in_password"],
|
||||
allowNameInPassword: passwordPolicy["allow_name_in_password"],
|
||||
minPasswordLength: passwordPolicy["min_password_length"],
|
||||
minNumberUpperCaseLetters:
|
||||
passwordPolicy["min_number_upper_case_letters"],
|
||||
minNumberLowerCaseLetters:
|
||||
passwordPolicy["min_number_lower_case_letters"],
|
||||
minNumberDigits: passwordPolicy["min_number_digits"],
|
||||
minNumberSpecialCharacters:
|
||||
passwordPolicy["min_number_special_characters"],
|
||||
minCategoriesPresence: passwordPolicy["min_categories_presence"],
|
||||
),
|
||||
dataConservationPolicy: ServerDataConservationPolicy(
|
||||
minInactiveAccountLifetime:
|
||||
dataConservationPolicy["min_inactive_account_lifetime"],
|
||||
minNotificationLifetime:
|
||||
dataConservationPolicy["min_notification_lifetime"],
|
||||
minCommentsLifetime: dataConservationPolicy["min_comments_lifetime"],
|
||||
minPostsLifetime: dataConservationPolicy["min_posts_lifetime"],
|
||||
minConversationMessagesLifetime:
|
||||
dataConservationPolicy["min_conversation_messages_lifetime"],
|
||||
minLikesLifetime: dataConservationPolicy["min_likes_lifetime"],
|
||||
),
|
||||
);
|
||||
minSupportedMobileVersion:
|
||||
Version.parse(response["min_supported_mobile_version"]),
|
||||
termsURL: response["terms_url"],
|
||||
playStoreURL: response["play_store_url"],
|
||||
androidDirectDownloadURL: response["android_direct_download_url"],
|
||||
passwordPolicy: PasswordPolicy(
|
||||
allowMailInPassword: passwordPolicy["allow_email_in_password"],
|
||||
allowNameInPassword: passwordPolicy["allow_name_in_password"],
|
||||
minPasswordLength: passwordPolicy["min_password_length"],
|
||||
minNumberUpperCaseLetters:
|
||||
passwordPolicy["min_number_upper_case_letters"],
|
||||
minNumberLowerCaseLetters:
|
||||
passwordPolicy["min_number_lower_case_letters"],
|
||||
minNumberDigits: passwordPolicy["min_number_digits"],
|
||||
minNumberSpecialCharacters:
|
||||
passwordPolicy["min_number_special_characters"],
|
||||
minCategoriesPresence: passwordPolicy["min_categories_presence"],
|
||||
),
|
||||
dataConservationPolicy: ServerDataConservationPolicy(
|
||||
minInactiveAccountLifetime:
|
||||
dataConservationPolicy["min_inactive_account_lifetime"],
|
||||
minNotificationLifetime:
|
||||
dataConservationPolicy["min_notification_lifetime"],
|
||||
minCommentsLifetime: dataConservationPolicy["min_comments_lifetime"],
|
||||
minPostsLifetime: dataConservationPolicy["min_posts_lifetime"],
|
||||
minConversationMessagesLifetime:
|
||||
dataConservationPolicy["min_conversation_messages_lifetime"],
|
||||
minLikesLifetime: dataConservationPolicy["min_likes_lifetime"],
|
||||
),
|
||||
conversationsPolicy: ConversationsPolicy(
|
||||
minMessageLen: conversationsPolicy["min_message_len"],
|
||||
maxMessageLen: conversationsPolicy["max_message_len"],
|
||||
allowedFilesType: conversationsPolicy["allowed_files_type"].cast<String>(),
|
||||
filesMaxSize: conversationsPolicy["files_max_size"],
|
||||
writingEventInterval: conversationsPolicy["writing_event_interval"],
|
||||
writingEventLifetime: conversationsPolicy["writing_event_lifetime"],
|
||||
));
|
||||
}
|
||||
|
||||
/// Get current server configuration, throwing if it is not loaded yet
|
||||
|
@ -57,6 +57,29 @@ class ServerDataConservationPolicy {
|
||||
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;
|
||||
@ -64,6 +87,7 @@ class ServerConfig {
|
||||
final String androidDirectDownloadURL;
|
||||
final PasswordPolicy passwordPolicy;
|
||||
final ServerDataConservationPolicy dataConservationPolicy;
|
||||
final ConversationsPolicy conversationsPolicy;
|
||||
|
||||
const ServerConfig({
|
||||
@required this.minSupportedMobileVersion,
|
||||
@ -72,10 +96,12 @@ class ServerConfig {
|
||||
@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(dataConservationPolicy != null),
|
||||
assert(conversationsPolicy != null);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.1.1"
|
||||
image:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
url: "https://pub.dartlang.org"
|
||||
|
Loading…
Reference in New Issue
Block a user