breaking: remove deprecated post diff socket calls

isekai-main
Barış Soner Uşaklı 3 years ago
parent 324262cbb5
commit 8117b7f22f

@ -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');

@ -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 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 () => {

Loading…
Cancel
Save