mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 08:31:22 +01:00
breaking: remove deprecated post diff socket calls
This commit is contained in:
@@ -22,7 +22,6 @@ require('./posts/move')(SocketPosts);
|
|||||||
require('./posts/votes')(SocketPosts);
|
require('./posts/votes')(SocketPosts);
|
||||||
require('./posts/bookmarks')(SocketPosts);
|
require('./posts/bookmarks')(SocketPosts);
|
||||||
require('./posts/tools')(SocketPosts);
|
require('./posts/tools')(SocketPosts);
|
||||||
require('./posts/diffs')(SocketPosts);
|
|
||||||
|
|
||||||
SocketPosts.reply = async function (socket, data) {
|
SocketPosts.reply = async function (socket, data) {
|
||||||
sockets.warnDeprecated(socket, 'POST /api/v3/topics/:tid');
|
sockets.warnDeprecated(socket, 'POST /api/v3/topics/:tid');
|
||||||
|
|||||||
@@ -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);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -18,6 +18,7 @@ const user = require('../src/user');
|
|||||||
const groups = require('../src/groups');
|
const groups = require('../src/groups');
|
||||||
const socketPosts = require('../src/socket.io/posts');
|
const socketPosts = require('../src/socket.io/posts');
|
||||||
const socketTopics = require('../src/socket.io/topics');
|
const socketTopics = require('../src/socket.io/topics');
|
||||||
|
const apiPosts = require('../src/api/posts');
|
||||||
const meta = require('../src/meta');
|
const meta = require('../src/meta');
|
||||||
const helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
|
|
||||||
@@ -625,28 +626,28 @@ describe('Post\'s', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not allow guests to view diffs', (done) => {
|
it('should not allow guests to view diffs', async () => {
|
||||||
socketPosts.getDiffs({ uid: 0 }, { pid: 1 }, (err) => {
|
let err = {};
|
||||||
assert.equal(err.message, '[[error:no-privileges]]');
|
try {
|
||||||
done();
|
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) => {
|
it('should allow registered-users group to view diffs', async () => {
|
||||||
socketPosts.getDiffs({ uid: 1 }, { pid: 1 }, (err, data) => {
|
const data = await apiPosts.getDiffs({ uid: 1 }, { pid: 1 });
|
||||||
assert.ifError(err);
|
|
||||||
|
|
||||||
assert.strictEqual('boolean', typeof data.editable);
|
assert.strictEqual('boolean', typeof data.editable);
|
||||||
assert.strictEqual(false, data.editable);
|
assert.strictEqual(false, data.editable);
|
||||||
|
|
||||||
assert.equal(true, Array.isArray(data.timestamps));
|
assert.equal(true, Array.isArray(data.timestamps));
|
||||||
assert.strictEqual(1, data.timestamps.length);
|
assert.strictEqual(1, data.timestamps.length);
|
||||||
|
|
||||||
assert.equal(true, Array.isArray(data.revisions));
|
assert.equal(true, Array.isArray(data.revisions));
|
||||||
assert.strictEqual(data.timestamps.length, data.revisions.length);
|
assert.strictEqual(data.timestamps.length, data.revisions.length);
|
||||||
['timestamp', 'username'].every(prop => Object.keys(data.revisions[0]).includes(prop));
|
['timestamp', 'username'].every(prop => Object.keys(data.revisions[0]).includes(prop));
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not delete first diff of a post', async () => {
|
it('should not delete first diff of a post', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user