mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-31 04:16:13 +02:00
breaking: remove socket.emit('topics.follow')
remove socket.emit('topics.changeWatching')
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const api = require('../api');
|
||||
const topics = require('../topics');
|
||||
const user = require('../user');
|
||||
const meta = require('../meta');
|
||||
const privileges = require('../privileges');
|
||||
const sockets = require('.');
|
||||
|
||||
const SocketTopics = module.exports;
|
||||
|
||||
@@ -46,32 +44,6 @@ SocketTopics.createTopicFromPosts = async function (socket, data) {
|
||||
return await topics.createTopicFromPosts(socket.uid, data.title, data.pids, data.fromTid);
|
||||
};
|
||||
|
||||
SocketTopics.changeWatching = async function (socket, data) {
|
||||
if (!data || !data.tid || !data.type) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
const commands = ['follow', 'unfollow', 'ignore'];
|
||||
if (!commands.includes(data.type)) {
|
||||
throw new Error('[[error:invalid-command]]');
|
||||
}
|
||||
|
||||
sockets.warnDeprecated(socket, 'PUT/DELETE /api/v3/topics/:tid/(follow|ignore)');
|
||||
await followCommand(data.type, socket, data.tid);
|
||||
};
|
||||
|
||||
SocketTopics.follow = async function (socket, tid) {
|
||||
sockets.warnDeprecated(socket, 'PUT /api/v3/topics/:tid/follow');
|
||||
await followCommand('follow', socket, tid);
|
||||
};
|
||||
|
||||
async function followCommand(method, socket, tid) {
|
||||
if (!socket.uid) {
|
||||
throw new Error('[[error:not-logged-in]]');
|
||||
}
|
||||
|
||||
await api.topics[method](socket, { tid });
|
||||
}
|
||||
|
||||
SocketTopics.isFollowed = async function (socket, tid) {
|
||||
const isFollowing = await topics.isFollowing([tid], socket.uid);
|
||||
return isFollowing[0];
|
||||
|
||||
@@ -127,7 +127,7 @@ module.exports = function (Topics) {
|
||||
throw new Error('[[error:no-topic]]');
|
||||
}
|
||||
|
||||
if (settings.followTopicsOnCreate) {
|
||||
if (uid > 0 && settings.followTopicsOnCreate) {
|
||||
await Topics.follow(postData.tid, uid);
|
||||
}
|
||||
const topicData = topics[0];
|
||||
|
||||
@@ -35,8 +35,8 @@ module.exports = function (Topics) {
|
||||
};
|
||||
|
||||
async function setWatching(method1, method2, hook, tid, uid) {
|
||||
if (parseInt(uid, 10) <= 0) {
|
||||
return;
|
||||
if (!(parseInt(uid, 10) > 0)) {
|
||||
throw new Error('[[error:not-logged-in]]');
|
||||
}
|
||||
const exists = await Topics.exists(tid);
|
||||
if (!exists) {
|
||||
|
||||
Reference in New Issue
Block a user