mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Can get last activity of groups
This commit is contained in:
parent
bf84f7814f
commit
beafd7a26b
@ -5,6 +5,7 @@ import { NewGroup } from "../entities/NewGroup";
|
||||
import { time } from "../utils/DateUtils";
|
||||
import { GroupSettings } from "../entities/GroupSettings";
|
||||
import { existsSync, unlinkSync } from "fs";
|
||||
import { PostsHelper } from "./PostsHelper";
|
||||
|
||||
/**
|
||||
* Groups helper
|
||||
@ -536,9 +537,11 @@ export class GroupsHelper {
|
||||
*
|
||||
* @param groupID Target group ID
|
||||
*/
|
||||
public static async GetLastActivity(groupID: number) : Promise<number> {
|
||||
// TODO URGENT : implement
|
||||
return groupID;
|
||||
public static async GetLastActivity(userID: number, groupID: number) : Promise<number> {
|
||||
|
||||
const lastPost = await PostsHelper.GetGroupPosts(userID, groupID, 0, 1);
|
||||
|
||||
return lastPost.length == 0 ? 0 : lastPost[0].timeCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ export class WebappHelper {
|
||||
|
||||
// Add groups to the list
|
||||
for(const g of groupsList) list.push(new UserMembershipEntry(
|
||||
await GroupsHelper.GetLastActivity(g), g, UserMembershipType.GROUP));
|
||||
await GroupsHelper.GetLastActivity(userID, g), g, UserMembershipType.GROUP));
|
||||
|
||||
// Sort entries by latest activities
|
||||
list.sort((a, b) => b.lastActivity - a.lastActivity);
|
||||
|
Loading…
Reference in New Issue
Block a user