1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 22:18:51 +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::new_group::NewGroup;
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::utils::date_utils::time;
@ -378,16 +378,15 @@ pub fn get_last_activity(user_id: &UserID, group_id: &GroupID) -> ResultBoxError
.set_limit(1)
.get_group(group_id)?;
match last_post.first() {
None => {
// No post was found
Ok(0)
}
let mut last_activity = last_post.first().map(|f| f.time_create).unwrap_or(0);
Some(p) => {
Ok(p.time_create)
for conv in conversations_helper::get_list_group(group_id)? {
if conv.last_activity > last_activity {
last_activity = conv.last_activity;
}
}
Ok(last_activity)
}
/// Set new settings to the group, except group logo