diff --git a/src/controllers/ConversationsController.ts b/src/controllers/ConversationsController.ts index 2dd1ac6..dcc6d7a 100644 --- a/src/controllers/ConversationsController.ts +++ b/src/controllers/ConversationsController.ts @@ -21,7 +21,7 @@ export class ConversationsController { const name = h.postString("name"); - const members = [...new Set(h.postNumbersList("users"))]; + const members = h.postNumbersSet("users"); // Check if the users exists for (const userID of members) { @@ -29,8 +29,8 @@ export class ConversationsController { h.error(404, "User " + userID + " not found!"); } - if(!members.includes(h.getUserId())) - members.push(h.getUserId()); + if(!members.has(h.getUserId())) + members.add(h.getUserId()); const conv : BaseConversation = { ownerID: h.getUserId(), @@ -149,7 +149,7 @@ export class ConversationsController { name: c.name.length > 0 ? c.name : false, following: c.following ? 1 : 0, saw_last_message: c.sawLastMessage ? 1 : 0, - members: c.members + members: [...c.members] }; } } \ No newline at end of file diff --git a/src/entities/Conversation.ts b/src/entities/Conversation.ts index da871f3..9ecec92 100644 --- a/src/entities/Conversation.ts +++ b/src/entities/Conversation.ts @@ -8,7 +8,7 @@ export interface BaseConversation { ownerID: number, name: string, following: boolean, - members: Array + members: Set } export interface Conversation extends BaseConversation { diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 043d092..1f1dcd1 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -271,7 +271,7 @@ export class ConversationsHelper { timeCreate: row.time_add, following: row.following, sawLastMessage: row.saw_last_message == 1, - members: [...await this.GetConversationMembers(row.id)] + members: await this.GetConversationMembers(row.id) } } } \ No newline at end of file