From f7418ccd47e6ff5e71d5a4a86c71f34deb1e7484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 9 Dec 2021 17:59:23 -0500 Subject: [PATCH] breaking: remove socket.emit('posts.bookmark/unbookmark') --- src/socket.io/posts.js | 1 - src/socket.io/posts/bookmarks.js | 16 --------------- test/posts.js | 34 +++++++++++--------------------- 3 files changed, 12 insertions(+), 39 deletions(-) delete mode 100644 src/socket.io/posts/bookmarks.js diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index f63b7e3e27..467b4cd8a0 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -20,7 +20,6 @@ const SocketPosts = module.exports; require('./posts/edit')(SocketPosts); require('./posts/move')(SocketPosts); require('./posts/votes')(SocketPosts); -require('./posts/bookmarks')(SocketPosts); require('./posts/tools')(SocketPosts); SocketPosts.reply = async function (socket, data) { diff --git a/src/socket.io/posts/bookmarks.js b/src/socket.io/posts/bookmarks.js deleted file mode 100644 index 4162047971..0000000000 --- a/src/socket.io/posts/bookmarks.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -const sockets = require('..'); -const api = require('../../api'); - -module.exports = function (SocketPosts) { - SocketPosts.bookmark = async function (socket, data) { - sockets.warnDeprecated(socket, 'PUT /api/v3/posts/:pid/bookmark'); - return await api.posts.bookmark(socket, data); - }; - - SocketPosts.unbookmark = async function (socket, data) { - sockets.warnDeprecated(socket, 'DELETE /api/v3/posts/:pid/bookmark'); - return await api.posts.unbookmark(socket, data); - }; -}; diff --git a/test/posts.js b/test/posts.js index 7da93f16b8..08100a30cf 100644 --- a/test/posts.js +++ b/test/posts.js @@ -282,28 +282,18 @@ describe('Post\'s', () => { }); describe('bookmarking', () => { - it('should bookmark a post', (done) => { - socketPosts.bookmark({ uid: voterUid }, { pid: postData.pid, room_id: `topic_${postData.tid}` }, (err, data) => { - assert.ifError(err); - assert.equal(data.isBookmarked, true); - posts.hasBookmarked(postData.pid, voterUid, (err, hasBookmarked) => { - assert.ifError(err); - assert.equal(hasBookmarked, true); - done(); - }); - }); - }); - - it('should unbookmark a post', (done) => { - socketPosts.unbookmark({ uid: voterUid }, { pid: postData.pid, room_id: `topic_${postData.tid}` }, (err, data) => { - assert.ifError(err); - assert.equal(data.isBookmarked, false); - posts.hasBookmarked([postData.pid], voterUid, (err, hasBookmarked) => { - assert.ifError(err); - assert.equal(hasBookmarked[0], false); - done(); - }); - }); + it('should bookmark a post', async () => { + const data = await apiPosts.bookmark({ uid: voterUid }, { pid: postData.pid, room_id: `topic_${postData.tid}` }); + assert.equal(data.isBookmarked, true); + const hasBookmarked = await posts.hasBookmarked(postData.pid, voterUid); + assert.equal(hasBookmarked, true); + }); + + it('should unbookmark a post', async () => { + const data = await apiPosts.unbookmark({ uid: voterUid }, { pid: postData.pid, room_id: `topic_${postData.tid}` }); + assert.equal(data.isBookmarked, false); + const hasBookmarked = await posts.hasBookmarked([postData.pid], voterUid); + assert.equal(hasBookmarked[0], false); }); });