Skip to content

Node.js based forum software built for the modern web

breaking: remove deprecated post diff socket calls

Barış Soner Uşaklı8117b7f22fd4
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 9fc33293cf..f63b7e3e27 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -22,7 +22,6 @@ require('./posts/move')(SocketPosts);
require('./posts/votes')(SocketPosts);
require('./posts/bookmarks')(SocketPosts);
require('./posts/tools')(SocketPosts);
-require('./posts/diffs')(SocketPosts);
SocketPosts.reply = async function (socket, data) {
sockets.warnDeprecated(socket, 'POST /api/v3/topics/:tid');
diff --git a/src/socket.io/posts/diffs.js b/src/socket.io/posts/diffs.js
deleted file mode 100644
index a1e2043243..0000000000
--- a/src/socket.io/posts/diffs.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict';
-
-const api = require('../../api');
-const websockets = require('..');
-
-module.exports = function (SocketPosts) {
- SocketPosts.getDiffs = async function (socket, data) {
- websockets.warnDeprecated(socket, 'GET /api/v3/posts/:pid/diffs');
- return await api.posts.getDiffs(socket, data);
- };
-
- SocketPosts.showPostAt = async function (socket, data) {
- websockets.warnDeprecated(socket, 'GET /api/v3/posts/:pid/diffs/:since');
- return await api.posts.loadDiff(socket, data);
- };
-
- SocketPosts.restoreDiff = async function (socket, data) {
- websockets.warnDeprecated(socket, 'PUT /api/v3/posts/:pid/diffs/:since');
- return await api.posts.restoreDiff(socket, data);
- };
-};
diff --git a/test/posts.js b/test/posts.js
index 268082ffb0..7da93f16b8 100644
--- a/test/posts.js
+++ b/test/posts.js
@@ -18,6 +18,7 @@ const user = require('../src/user');
const groups = require('../src/groups');
const socketPosts = require('../src/socket.io/posts');
const socketTopics = require('../src/socket.io/topics');
+const apiPosts = require('../src/api/posts');
const meta = require('../src/meta');
const helpers = require('./helpers');
@@ -625,28 +626,28 @@ describe('Post\'s', () => {
});
});
- it('should not allow guests to view diffs', (done) => {
- socketPosts.getDiffs({ uid: 0 }, { pid: 1 }, (err) => {
- assert.equal(err.message, '[[error:no-privileges]]');
- done();
- });
+ it('should not allow guests to view diffs', async () => {
+ let err = {};
+ try {
+ await apiPosts.getDiffs({ uid: 0 }, { pid: 1 });
+ } catch (_err) {
+ err = _err;
+ }
+ assert.strictEqual(err.message, '[[error:no-privileges]]');
});
- it('should allow registered-users group to view diffs', (done) => {
- socketPosts.getDiffs({ uid: 1 }, { pid: 1 }, (err, data) => {
- assert.ifError(err);
+ it('should allow registered-users group to view diffs', async () => {
+ const data = await apiPosts.getDiffs({ uid: 1 }, { pid: 1 });
- assert.strictEqual('boolean', typeof data.editable);
- assert.strictEqual(false, data.editable);
+ assert.strictEqual('boolean', typeof data.editable);
+ assert.strictEqual(false, data.editable);
- assert.equal(true, Array.isArray(data.timestamps));
- assert.strictEqual(1, data.timestamps.length);
+ assert.equal(true, Array.isArray(data.timestamps));
+ assert.strictEqual(1, data.timestamps.length);
- assert.equal(true, Array.isArray(data.revisions));
- assert.strictEqual(data.timestamps.length, data.revisions.length);
- ['timestamp', 'username'].every(prop => Object.keys(data.revisions[0]).includes(prop));
- done();
- });
+ assert.equal(true, Array.isArray(data.revisions));
+ assert.strictEqual(data.timestamps.length, data.revisions.length);
+ ['timestamp', 'username'].every(prop => Object.keys(data.revisions[0]).includes(prop));
});
it('should not delete first diff of a post', async () => {