Skip to content

Node.js based forum software built for the modern web

breaking: remove setTopicSort/setCategorySort

Barış Soner Uşaklı6dcdf1d342b2
diff --git a/src/socket.io/user.js b/src/socket.io/user.js
index a9f105ef48..66a7c54820 100644
--- a/src/socket.io/user.js
+++ b/src/socket.io/user.js
@@ -136,24 +136,6 @@ SocketUser.saveSettings = async function (socket, data) {
return settings;
};
-SocketUser.setTopicSort = async function (socket, sort) {
- sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/settings');
- await api.users.updateSetting(socket, {
- uid: socket.uid,
- setting: 'topicPostSort',
- value: sort,
- });
-};
-
-SocketUser.setCategorySort = async function (socket, sort) {
- sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/settings');
- await api.users.updateSetting(socket, {
- uid: socket.uid,
- setting: 'categoryTopicSort',
- value: sort,
- });
-};
-
SocketUser.getUnreadCount = async function (socket) {
if (!socket.uid) {
return 0;
diff --git a/test/user.js b/test/user.js
index 372d334bf6..fb588e3fbd 100644
--- a/test/user.js
+++ b/test/user.js
@@ -1927,6 +1927,72 @@ describe('User', () => {
done();
});
});
+
+ it('should get unread count 0 for guest', async () => {
+ const count = await socketUser.getUnreadCount({ uid: 0 });
+ assert.strictEqual(count, 0);
+ });
+
+ it('should get unread count for user', async () => {
+ const count = await socketUser.getUnreadCount({ uid: testUid });
+ assert.strictEqual(count, 2);
+ });
+
+ it('should get unread chat count 0 for guest', async () => {
+ const count = await socketUser.getUnreadChatCount({ uid: 0 });
+ assert.strictEqual(count, 0);
+ });
+
+ it('should get unread chat count for user', async () => {
+ const count = await socketUser.getUnreadChatCount({ uid: testUid });
+ assert.strictEqual(count, 0);
+ });
+
+ it('should get unread counts 0 for guest', async () => {
+ const counts = await socketUser.getUnreadCounts({ uid: 0 });
+ assert.deepStrictEqual(counts, {});
+ });
+
+ it('should get unread counts for user', async () => {
+ const counts = await socketUser.getUnreadCounts({ uid: testUid });
+ assert.deepStrictEqual(counts, {
+ unreadChatCount: 0,
+ unreadCounts: {
+ '': 2,
+ new: 2,
+ unreplied: 2,
+ watched: 0,
+ },
+ unreadNewTopicCount: 2,
+ unreadNotificationCount: 0,
+ unreadTopicCount: 2,
+ unreadUnrepliedTopicCount: 2,
+ unreadWatchedTopicCount: 0,
+ });
+ });
+
+ it('should get user data by uid', async () => {
+ const userData = await socketUser.getUserByUID({ uid: testUid }, testUid);
+ assert.strictEqual(userData.uid, testUid);
+ });
+
+ it('should get user data by username', async () => {
+ const userData = await socketUser.getUserByUsername({ uid: testUid }, 'John Smith');
+ assert.strictEqual(userData.uid, testUid);
+ });
+
+ it('should get user data by email', async () => {
+ const userData = await socketUser.getUserByEmail({ uid: testUid }, '[email protected]');
+ assert.strictEqual(userData.uid, testUid);
+ });
+
+ it('should check/consent gdpr status', async () => {
+ const consent = await socketUser.gdpr.check({ uid: testUid }, { uid: testUid });
+ assert(!consent);
+ await socketUser.gdpr.consent({ uid: testUid });
+ const consentAfter = await socketUser.gdpr.check({ uid: testUid }, { uid: testUid });
+ assert(consentAfter);
+ });
});
describe('approval queue', () => {