mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-23 18:11:40 +00:00
Returns the list of conversations with the memberships
This commit is contained in:
@ -3,6 +3,8 @@ import { WebappHelper } from "../helpers/WebappHelper";
|
||||
import { UserMembershipType } from "../entities/UserMembershipEntry";
|
||||
import { FriendsController } from "./FriendsController";
|
||||
import { Friend } from "../entities/Friend";
|
||||
import { ConversationsController } from "./ConversationsController";
|
||||
import { Conversation } from "../entities/Conversation";
|
||||
|
||||
|
||||
/**
|
||||
@ -21,15 +23,33 @@ export class WebAppControllers {
|
||||
|
||||
const list = await WebappHelper.GetUserMemberships(h.getUserId());
|
||||
|
||||
h.send(list.map((l) => l.type == UserMembershipType.FRIEND ? {
|
||||
// In case of friend
|
||||
type: "friend",
|
||||
friend: FriendsController.FriendToAPI(<Friend>l.el)
|
||||
} : {
|
||||
// In case of group
|
||||
type: "group",
|
||||
id: l.el,
|
||||
last_activity: l.lastActivity
|
||||
h.send(list.map((l) => {
|
||||
switch(l.type) {
|
||||
|
||||
case UserMembershipType.FRIEND:
|
||||
return {
|
||||
type: "friend",
|
||||
friend: FriendsController.FriendToAPI(<Friend>l.el)
|
||||
};
|
||||
|
||||
|
||||
case UserMembershipType.GROUP:
|
||||
return {
|
||||
type: "group",
|
||||
id: l.el,
|
||||
last_activity: l.lastActivity
|
||||
}
|
||||
|
||||
|
||||
case UserMembershipType.CONVERSATION:
|
||||
return {
|
||||
type: "conversation",
|
||||
conv: ConversationsController.ConversationToAPI(<Conversation>l.el)
|
||||
}
|
||||
|
||||
default:
|
||||
h.error(500, "Unsupported membership type detected!");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user