1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00

Updated conversations policy

This commit is contained in:
Pierre HUBERT 2021-03-12 16:19:07 +01:00
parent a4181e3d42
commit e02ab259b6
3 changed files with 66 additions and 32 deletions

View File

@ -19,6 +19,7 @@ class ServerConfigurationHelper {
final passwordPolicy = response["password_policy"]; final passwordPolicy = response["password_policy"];
final dataConservationPolicy = response["data_conservation_policy"]; final dataConservationPolicy = response["data_conservation_policy"];
final conversationsPolicy = response["conversations_policy"];
_config = ServerConfig( _config = ServerConfig(
minSupportedMobileVersion: minSupportedMobileVersion:
@ -50,7 +51,14 @@ class ServerConfigurationHelper {
dataConservationPolicy["min_conversation_messages_lifetime"], dataConservationPolicy["min_conversation_messages_lifetime"],
minLikesLifetime: dataConservationPolicy["min_likes_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 /// Get current server configuration, throwing if it is not loaded yet

View File

@ -57,6 +57,29 @@ class ServerDataConservationPolicy {
assert(minLikesLifetime != 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 { class ServerConfig {
final Version minSupportedMobileVersion; final Version minSupportedMobileVersion;
final String termsURL; final String termsURL;
@ -64,6 +87,7 @@ class ServerConfig {
final String androidDirectDownloadURL; final String androidDirectDownloadURL;
final PasswordPolicy passwordPolicy; final PasswordPolicy passwordPolicy;
final ServerDataConservationPolicy dataConservationPolicy; final ServerDataConservationPolicy dataConservationPolicy;
final ConversationsPolicy conversationsPolicy;
const ServerConfig({ const ServerConfig({
@required this.minSupportedMobileVersion, @required this.minSupportedMobileVersion,
@ -72,10 +96,12 @@ class ServerConfig {
@required this.androidDirectDownloadURL, @required this.androidDirectDownloadURL,
@required this.passwordPolicy, @required this.passwordPolicy,
@required this.dataConservationPolicy, @required this.dataConservationPolicy,
@required this.conversationsPolicy,
}) : assert(minSupportedMobileVersion != null), }) : assert(minSupportedMobileVersion != null),
assert(termsURL != null), assert(termsURL != null),
assert(playStoreURL != null), assert(playStoreURL != null),
assert(androidDirectDownloadURL != null), assert(androidDirectDownloadURL != null),
assert(passwordPolicy != null), assert(passwordPolicy != null),
assert(dataConservationPolicy != null); assert(dataConservationPolicy != null),
assert(conversationsPolicy != null);
} }

View File

@ -290,7 +290,7 @@ packages:
source: hosted source: hosted
version: "0.1.1" version: "0.1.1"
image: image:
dependency: "direct main" dependency: transitive
description: description:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"