mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	breaking: remove setTopicSort/setCategorySort
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										66
									
								
								test/user.js
									
									
									
									
									
								
							
							
						
						
									
										66
									
								
								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 }, 'john@example.com');
 | 
			
		||||
			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', () => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user