From ff84d6c52fd573334357d4f725a69dd442803361 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Mon, 27 Sep 2021 11:22:12 -0600 Subject: [PATCH] Add more chat hooks, replace toobig.jpg (#9843) * feat: more hooks for messaging for use in global chat plugin * fix: replace toobig.jpg toobig.png is a real 10000x10000 image --- src/messaging/rooms.js | 44 +++++++++++++++++++++++------------------ test/files/toobig.jpg | Bin 4856 -> 0 bytes test/files/toobig.png | Bin 0 -> 317110 bytes test/uploads.js | 4 ++-- 4 files changed, 27 insertions(+), 21 deletions(-) delete mode 100644 test/files/toobig.jpg create mode 100644 test/files/toobig.png diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js index 09aa643fbe..6193885adb 100644 --- a/src/messaging/rooms.js +++ b/src/messaging/rooms.js @@ -69,22 +69,27 @@ module.exports = function (Messaging) { Messaging.getUserCountInRoom = async roomId => db.sortedSetCard(`chat:room:${roomId}:uids`); - Messaging.isRoomOwner = async (uid, roomId) => { - const owner = await db.getObjectField(`chat:room:${roomId}`, 'owner'); - return parseInt(uid, 10) === parseInt(owner, 10); + Messaging.isRoomOwner = async (uid, roomId, knownOwner) => { + const owner = (knownOwner == null) ? await db.getObjectField(`chat:room:${roomId}`, 'owner') : knownOwner; + const isOwner = parseInt(uid, 10) === parseInt(owner, 10); + + const payload = await plugins.hooks.fire('filter:messaging.isRoomOwner', { uid, roomId, owner, isOwner }); + return payload.isOwner; }; Messaging.addUsersToRoom = async function (uid, uids, roomId) { - const now = Date.now(); - const timestamps = uids.map(() => now); const inRoom = await Messaging.isUserInRoom(uid, roomId); - if (!inRoom) { + const payload = await plugins.hooks.fire('filter:messaging.addUsersToRoom', { uid, uids, roomId, inRoom }); + + if (!payload.inRoom) { throw new Error('[[error:cant-add-users-to-chat-room]]'); } - await db.sortedSetAdd(`chat:room:${roomId}:uids`, timestamps, uids); - await updateGroupChatField([roomId]); - await Promise.all(uids.map(uid => Messaging.addSystemMessage('user-join', uid, roomId))); + const now = Date.now(); + const timestamps = payload.uids.map(() => now); + await db.sortedSetAdd(`chat:room:${payload.roomId}:uids`, timestamps, payload.uids); + await updateGroupChatField([payload.roomId]); + await Promise.all(payload.uids.map(uid => Messaging.addSystemMessage('user-join', uid, payload.roomId))); }; Messaging.removeUsersFromRoom = async (uid, uids, roomId) => { @@ -92,15 +97,16 @@ module.exports = function (Messaging) { Messaging.isRoomOwner(uid, roomId), Messaging.getUserCountInRoom(roomId), ]); + const payload = await plugins.hooks.fire('filter:messaging.removeUsersFromRoom', { uid, uids, roomId, isOwner, userCount }); - if (!isOwner) { + if (!payload.isOwner) { throw new Error('[[error:cant-remove-users-from-chat-room]]'); } - if (userCount === 2) { + if (payload.userCount === 2) { throw new Error('[[error:cant-remove-last-user]]'); } - await Messaging.leaveRoom(uids, roomId); + await Messaging.leaveRoom(payload.uids, payload.roomId); }; Messaging.isGroupChat = async function (roomId) { @@ -170,10 +176,10 @@ module.exports = function (Messaging) { db.getObjectField(`chat:room:${roomId}`, 'owner'), ]); - return users.map((user) => { - user.isOwner = parseInt(user.uid, 10) === parseInt(ownerId, 10); + return Promise.all(users.map(async (user) => { + user.isOwner = await Messaging.isRoomOwner(user.uid, roomId, ownerId); return user; - }); + })); }; Messaging.renameRoom = async function (uid, roomId, newName) { @@ -220,7 +226,7 @@ module.exports = function (Messaging) { return null; } - const [roomData, canReply, users, messages, isAdminOrGlobalMod] = await Promise.all([ + const [room, canReply, users, messages, isAdminOrGlobalMod] = await Promise.all([ Messaging.getRoomData(data.roomId), Messaging.canReply(data.roomId, uid), Messaging.getUsersInRoom(data.roomId, 0, -1), @@ -233,9 +239,8 @@ module.exports = function (Messaging) { user.isAdminOrGlobalMod(uid), ]); - const room = roomData; room.messages = messages; - room.isOwner = parseInt(room.owner, 10) === parseInt(uid, 10); + room.isOwner = await Messaging.isRoomOwner(uid, room.roomId, room.owner); room.users = users.filter(user => user && parseInt(user.uid, 10) && parseInt(user.uid, 10) !== parseInt(uid, 10)); room.canReply = canReply; room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : users.length > 2; @@ -245,6 +250,7 @@ module.exports = function (Messaging) { room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2; room.isAdminOrGlobalMod = isAdminOrGlobalMod; - return room; + const payload = await plugins.hooks.fire('filter:messaging.loadRoom', { uid, data, room }); + return payload.room; }; }; diff --git a/test/files/toobig.jpg b/test/files/toobig.jpg deleted file mode 100644 index e25c2d30156d39d0930a54975211d7339c83b73b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4856 zcmb7IXH-+$w%$2(A|+zbfPg>{q$*XZ2WbLAB%y^W8W0RcI!F;gP`aRibZH_;4}s9T zbP9dfzAgC@=ZZaNkKLmDk@59S{gc9S{hnfI(h~$9sLD*T3Rp@_yPkXBNHPX zm>I&%2qF87=S4u|jpw^4DQOt#Xz9q&|EHZb0ub6mvQdC|fIlE03JB<|72pH_5EWT1 zS?_NnGf`4e)6mh=l5t&T;9NO16)hDl4K>Yq4jG3~a#K-Xyd|zj!=r2!LrceU$@yj6 z0F+k(nIU=i(c{3N*rv-cxQd#~yDNOs`tHrDDA&^dUmN6lZ2#i=-*n{q=X_-B8st1q z?$Cc=5af?r6c<^z^(ZeXpN#<*D9AX30s<%jM-Ks-1uo&=qW{ax;Mhau3wL_u>ZxK< z{l`7$cP-8qa%;w69poorMw6IJB(_ebHJ)?`AFu?F*I-4}X_)AjmqIhlVvz7B9bP-l zFdJ^%EURy5BkzNMt(=2i9{_lrJ!u@zNAAcRc_Y zuK^Sv&oRb_=c6D1(4Wu$vES^X$_a1)Lv8jJ;J5|=AODl^-#my-0B~Uk0HD9qM?E0k zG$62p!ixU5>1Z_{D8aXR{loVSm}igZK_t`vc}e{`0Q6hcKjh-upt6;#(&n$(M?yCl z&3G-DiOt3j{sC85>?nR+fpQ<+6Ahtx=%^YXE!R#-ZjERFb_RggfJ-ay22@&kTmvdG zjxL&W@{yn3(k=4!`2VPi!N*o|H)^x~B&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|0K;bmy!!7w4(7$8}SHW>>Wp^YWt za+0j+!P(;D2 z=&16K!R|hdAjY}?N06XRfWuGF#-|a+XcO}AGPLnvm=J9YkSs-;jD?LVN1G`>c>aYR z?gd~G?b2m=bC7(Tvb1_ z#vPvaD2KuZbk$iRS&lXt3lpJ@0pg`-)zRsd~Qqi(!EXHwe977XwC}Y1<9#s z&dMghw`VL>P{Tm!gdaBMi|d!4mtmSbsbgi zKn3-sZz#ouifmAF zu<0ywC~UyOSt41EHW>>Op^X9JrD)^92*W|G&6}1TopsK=zq { }); it('should fail to upload image to post if image dimensions are too big', (done) => { - helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/toobig.jpg'), {}, jar, csrf_token, (err, res, body) => { + helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/toobig.png'), {}, jar, csrf_token, (err, res, body) => { assert.ifError(err); assert.strictEqual(res.statusCode, 500); assert(body && body.status && body.status.message); - assert.strictEqual(body.status.message, 'Input image exceeds pixel limit'); + assert.strictEqual(body.status.message, 'Image dimensions are too big'); done(); }); });