diff --git a/apps/meteor/app/lib/server/methods/createChannel.ts b/apps/meteor/app/lib/server/methods/createChannel.ts index 3b106ad5acff..210dada14971 100644 --- a/apps/meteor/app/lib/server/methods/createChannel.ts +++ b/apps/meteor/app/lib/server/methods/createChannel.ts @@ -25,7 +25,7 @@ export const createChannelMethod = async ( name: string, members: string[], readOnly = false, - customFields: Record = {}, + customFields?: Record, extraData: Record = {}, excludeSelf = false, ) => { @@ -53,7 +53,7 @@ export const createChannelMethod = async ( } return createRoom('c', name, user, members, excludeSelf, readOnly, { - customFields, + ...(customFields && Object.keys(customFields).length && { customFields }), ...extraData, }); }; diff --git a/apps/meteor/app/lib/server/methods/createPrivateGroup.ts b/apps/meteor/app/lib/server/methods/createPrivateGroup.ts index f07e37109901..413b1066a0cd 100644 --- a/apps/meteor/app/lib/server/methods/createPrivateGroup.ts +++ b/apps/meteor/app/lib/server/methods/createPrivateGroup.ts @@ -25,7 +25,7 @@ export const createPrivateGroupMethod = async ( name: string, members: string[], readOnly = false, - customFields: Record = {}, + customFields?: Record, extraData: Record = {}, excludeSelf = false, ): Promise< @@ -51,7 +51,7 @@ export const createPrivateGroupMethod = async ( } return createRoom('p', name, user, members, excludeSelf, readOnly, { - customFields, + ...(customFields && Object.keys(customFields).length && { customFields }), ...extraData, }); }; diff --git a/apps/meteor/lib/publishFields.ts b/apps/meteor/lib/publishFields.ts index c4965bb1c6b0..5f5170aed3a5 100644 --- a/apps/meteor/lib/publishFields.ts +++ b/apps/meteor/lib/publishFields.ts @@ -14,6 +14,7 @@ export const subscriptionFields = { roles: 1, unread: 1, prid: 1, + customFields: 1, userMentions: 1, groupMentions: 1, archived: 1, diff --git a/apps/meteor/tests/end-to-end/api/rooms.ts b/apps/meteor/tests/end-to-end/api/rooms.ts index 110eb22a83de..7e4846717656 100644 --- a/apps/meteor/tests/end-to-end/api/rooms.ts +++ b/apps/meteor/tests/end-to-end/api/rooms.ts @@ -1255,21 +1255,7 @@ describe('[Rooms]', () => { let testChannel: IRoom; let testGroup: IRoom; let testDM: IRoom; - const expectedKeys = [ - '_id', - 'name', - 'fname', - 't', - 'msgs', - 'usersCount', - 'u', - 'customFields', - 'ts', - 'ro', - 'sysMes', - 'default', - '_updatedAt', - ]; + const expectedKeys = ['_id', 'name', 'fname', 't', 'msgs', 'usersCount', 'u', 'ts', 'ro', 'sysMes', 'default', '_updatedAt']; const testChannelName = `channel.test.${Date.now()}-${Math.random()}`; const testGroupName = `group.test.${Date.now()}-${Math.random()}`; let user: TestUser;