Merge pull request 'imp-fixes' (#3) from imp-fixes into main

Reviewed-on: #3
This commit is contained in:
Sarah Jamie Lewis 2022-04-27 22:41:03 +00:00
commit 4dafd66fed
2 changed files with 20 additions and 1 deletions

View File

@ -12,6 +12,7 @@ pub enum Event {
},
NewMessageFromPeer {
conversation_id: i32,
handle: String,
timestamp_received: DateTime<FixedOffset>,
message: String,
@ -45,6 +46,7 @@ impl From<&CwtchEvent> for Event {
data: cwtch_event.data.clone(),
},
"NewMessageFromPeer" => Event::NewMessageFromPeer {
conversation_id: cwtch_event.data["ConversationID"].parse().unwrap_or(-2),
handle: cwtch_event.data["RemotePeer"].clone(),
timestamp_received: DateTime::parse_from_rfc3339(cwtch_event.data["TimestampReceived"].as_str()).unwrap(),
message: cwtch_event.data["Data"].clone(),

View File

@ -18,9 +18,13 @@ pub enum NewContactPolicy {
pub struct Behaviour {
/// The bot will enable experimental feautres (required for any experiments to be used)
pub proto_experiments: bool,
/// The bot will use the file sharing experiment
/// The bot will enable the file sharing experiment
pub proto_experiment_fileshare: bool,
/// The bot will enable the groups experiment
pub proto_experiment_groups: bool,
/// The profile name the bot will share with accepted conversations
pub profile_name: String,
/// The profile pic the bot with share with accepted conversations IF the file share exoeriment is enabled
@ -40,6 +44,7 @@ impl BehaviourBuilder {
behaviour: Behaviour {
proto_experiments: false,
proto_experiment_fileshare: false,
proto_experiment_groups: false,
new_contant_policy: NewContactPolicy::Ignore,
profile_name: "".to_string(),
profile_pic_path: None,
@ -51,8 +56,15 @@ impl BehaviourBuilder {
self.behaviour
}
pub fn groups(mut self, val: bool) -> Self {
self.behaviour.proto_experiment_groups = val;
self.behaviour.proto_experiments = true;
self
}
pub fn fileshare(mut self, val: bool) -> Self {
self.behaviour.proto_experiment_fileshare = val;
self.behaviour.proto_experiments = true;
self
}
@ -151,6 +163,11 @@ impl Imp {
.Experiments
.insert(Experiments::FileSharingExperiment.to_key_string(), true);
}
if self.behaviour.proto_experiment_groups {
settings
.Experiments
.insert(Experiments::GroupExperiment.to_key_string(), true);
}
match settings.save(self.cwtch.as_ref()) {
Ok(_) => (),
Err(e) => println!("ERROR: could not save settings: {}", e),