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

Update the way group last activity is retrieved

This commit is contained in:
Pierre HUBERT 2021-04-05 16:40:04 +02:00
parent 7902981c22
commit 6365e2d2b3

View File

@ -9,7 +9,7 @@ use crate::data::group_id::GroupID;
use crate::data::group_member::{GroupMember, GroupMembershipLevel}; use crate::data::group_member::{GroupMember, GroupMembershipLevel};
use crate::data::new_group::NewGroup; use crate::data::new_group::NewGroup;
use crate::data::user::UserID; use crate::data::user::UserID;
use crate::helpers::{database, likes_helper, notifications_helper, posts_helper, conversations_helper}; use crate::helpers::{conversations_helper, database, likes_helper, notifications_helper, posts_helper};
use crate::helpers::likes_helper::LikeType; use crate::helpers::likes_helper::LikeType;
use crate::utils::date_utils::time; use crate::utils::date_utils::time;
@ -378,16 +378,15 @@ pub fn get_last_activity(user_id: &UserID, group_id: &GroupID) -> ResultBoxError
.set_limit(1) .set_limit(1)
.get_group(group_id)?; .get_group(group_id)?;
match last_post.first() { let mut last_activity = last_post.first().map(|f| f.time_create).unwrap_or(0);
None => {
// No post was found for conv in conversations_helper::get_list_group(group_id)? {
Ok(0) if conv.last_activity > last_activity {
last_activity = conv.last_activity;
}
} }
Some(p) => { Ok(last_activity)
Ok(p.time_create)
}
}
} }
/// Set new settings to the group, except group logo /// Set new settings to the group, except group logo