Skip to content

Node.js based forum software built for the modern web

fix: always return empty array if its not set

Barış Soner Uşaklı5c2086107efc
diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js
index c38ba02e5f..300f928e86 100644
--- a/src/messaging/rooms.js
+++ b/src/messaging/rooms.js
@@ -53,9 +53,9 @@ module.exports = function (Messaging) {
data.groupChat = parseInt(data.groupChat, 10) === 1;
}
- if (data.hasOwnProperty('groups')) {
+ if (data.hasOwnProperty('groups') || !fields.length || fields.includes('groups')) {
try {
- data.groups = JSON.parse(data.groups);
+ data.groups = JSON.parse(data.groups || '[]');
} catch (err) {
winston.error(err.stack);
data.groups = [];