| 
									
										
										
										
											2015-01-03 20:07:09 -05:00
										 |  |  | 'use strict'; | 
					
						
							| 
									
										
										
										
											2017-02-17 21:55:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | const assert = require('assert'); | 
					
						
							|  |  |  | const nconf = require('nconf'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-18 12:08:34 -05:00
										 |  |  | const request = require('../src/request'); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | const db = require('./mocks/databasemock'); | 
					
						
							|  |  |  | const Categories = require('../src/categories'); | 
					
						
							|  |  |  | const Topics = require('../src/topics'); | 
					
						
							|  |  |  | const User = require('../src/user'); | 
					
						
							|  |  |  | const groups = require('../src/groups'); | 
					
						
							|  |  |  | const privileges = require('../src/privileges'); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | describe('Categories', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 	let categoryObj; | 
					
						
							|  |  |  | 	let posterUid; | 
					
						
							|  |  |  | 	let adminUid; | 
					
						
							| 
									
										
										
										
											2016-10-11 16:06:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-22 11:44:32 -04:00
										 |  |  | 	before(async () => { | 
					
						
							|  |  |  | 		posterUid = await User.create({ username: 'poster' }); | 
					
						
							|  |  |  | 		adminUid = await User.create({ username: 'admin' }); | 
					
						
							|  |  |  | 		await groups.join('administrators', adminUid); | 
					
						
							| 
									
										
										
										
											2016-10-11 16:06:42 +03:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-06 13:21:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should create a new category', (done) => { | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 		Categories.create({ | 
					
						
							| 
									
										
										
										
											2018-11-30 14:25:45 -05:00
										 |  |  | 			name: 'Test Category & NodeBB', | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 			description: 'Test category created by testing script', | 
					
						
							|  |  |  | 			icon: 'fa-check', | 
					
						
							|  |  |  | 			blockclass: 'category-blue', | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 			order: '5', | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		}, (err, category) => { | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 			assert.ifError(err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			categoryObj = category; | 
					
						
							|  |  |  | 			done(); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should retrieve a newly created category by its ID', (done) => { | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 		Categories.getCategoryById({ | 
					
						
							|  |  |  | 			cid: categoryObj.cid, | 
					
						
							|  |  |  | 			start: 0, | 
					
						
							|  |  |  | 			stop: -1, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 			uid: 0, | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		}, (err, categoryData) => { | 
					
						
							| 
									
										
										
										
											2018-12-01 17:15:38 -05:00
										 |  |  | 			assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			assert(categoryData); | 
					
						
							| 
									
										
										
										
											2018-11-30 14:25:45 -05:00
										 |  |  | 			assert.equal('Test Category & NodeBB', categoryData.name); | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 			assert.equal(categoryObj.description, categoryData.description); | 
					
						
							| 
									
										
										
										
											2018-10-20 17:55:13 -04:00
										 |  |  | 			assert.strictEqual(categoryObj.disabled, 0); | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 			done(); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should return null if category does not exist', (done) => { | 
					
						
							| 
									
										
										
										
											2018-12-01 17:15:38 -05:00
										 |  |  | 		Categories.getCategoryById({ | 
					
						
							|  |  |  | 			cid: 123123123, | 
					
						
							|  |  |  | 			start: 0, | 
					
						
							|  |  |  | 			stop: -1, | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		}, (err, categoryData) => { | 
					
						
							| 
									
										
										
										
											2018-12-01 17:15:38 -05:00
										 |  |  | 			assert.ifError(err); | 
					
						
							|  |  |  | 			assert.strictEqual(categoryData, null); | 
					
						
							|  |  |  | 			done(); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-10-18 00:14:28 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should get all categories', (done) => { | 
					
						
							| 
									
										
										
										
											2024-01-30 17:47:06 -05:00
										 |  |  | 		Categories.getAllCategories((err, data) => { | 
					
						
							| 
									
										
										
										
											2018-12-05 11:22:44 -05:00
										 |  |  | 			assert.ifError(err); | 
					
						
							|  |  |  | 			assert(Array.isArray(data)); | 
					
						
							|  |  |  | 			assert.equal(data[0].cid, categoryObj.cid); | 
					
						
							|  |  |  | 			done(); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-18 12:08:34 -05:00
										 |  |  | 	it('should load a category route', async () => { | 
					
						
							|  |  |  | 		const { response, body } = await request.get(`${nconf.get('url')}/api/category/${categoryObj.cid}/test-category`); | 
					
						
							|  |  |  | 		assert.equal(response.statusCode, 200); | 
					
						
							|  |  |  | 		assert.equal(body.name, 'Test Category & NodeBB'); | 
					
						
							|  |  |  | 		assert(body); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	describe('Categories.getRecentTopicReplies', () => { | 
					
						
							|  |  |  | 		it('should not throw', (done) => { | 
					
						
							| 
									
										
										
										
											2016-08-26 19:33:16 +03:00
										 |  |  | 			Categories.getCategoryById({ | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							| 
									
										
										
										
											2021-02-03 23:59:08 -07:00
										 |  |  | 				set: `cid:${categoryObj.cid}:tids`, | 
					
						
							| 
									
										
										
										
											2016-08-26 19:33:16 +03:00
										 |  |  | 				reverse: true, | 
					
						
							|  |  |  | 				start: 0, | 
					
						
							|  |  |  | 				stop: -1, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				uid: 0, | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, categoryData) => { | 
					
						
							| 
									
										
										
										
											2016-08-26 19:33:16 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				Categories.getRecentTopicReplies(categoryData, 0, {}, (err) => { | 
					
						
							| 
									
										
										
										
											2016-08-26 19:33:16 +03:00
										 |  |  | 					assert.ifError(err); | 
					
						
							|  |  |  | 					done(); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	describe('.getCategoryTopics', () => { | 
					
						
							|  |  |  | 		it('should return a list of topics', (done) => { | 
					
						
							| 
									
										
										
										
											2014-11-06 18:14:07 -05:00
										 |  |  | 			Categories.getCategoryTopics({ | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				start: 0, | 
					
						
							|  |  |  | 				stop: 10, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				uid: 0, | 
					
						
							| 
									
										
										
										
											2019-07-03 12:48:26 -04:00
										 |  |  | 				sort: 'oldest_to_newest', | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, result) => { | 
					
						
							| 
									
										
										
										
											2016-08-16 19:46:59 +02:00
										 |  |  | 				assert.equal(err, null); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-26 17:17:34 -05:00
										 |  |  | 				assert(Array.isArray(result.topics)); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				assert(result.topics.every(topic => topic instanceof Object)); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2014-11-06 18:14:07 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should return a list of topics by a specific user', (done) => { | 
					
						
							| 
									
										
										
										
											2014-11-06 18:14:07 -05:00
										 |  |  | 			Categories.getCategoryTopics({ | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				start: 0, | 
					
						
							|  |  |  | 				stop: 10, | 
					
						
							|  |  |  | 				uid: 0, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				targetUid: 1, | 
					
						
							| 
									
										
										
										
											2019-07-03 12:48:26 -04:00
										 |  |  | 				sort: 'oldest_to_newest', | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, result) => { | 
					
						
							| 
									
										
										
										
											2016-08-16 19:46:59 +02:00
										 |  |  | 				assert.equal(err, null); | 
					
						
							| 
									
										
										
										
											2014-11-06 18:14:07 -05:00
										 |  |  | 				assert(Array.isArray(result.topics)); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				assert(result.topics.every(topic => topic instanceof Object && topic.uid === '1')); | 
					
						
							| 
									
										
										
										
											2014-11-06 18:14:07 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2013-10-12 11:06:43 -04:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	describe('Categories.moveRecentReplies', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		let moveCid; | 
					
						
							|  |  |  | 		let moveTid; | 
					
						
							| 
									
										
										
										
											2023-09-22 11:44:32 -04:00
										 |  |  | 		before(async () => { | 
					
						
							|  |  |  | 			const [category, topic] = await Promise.all([ | 
					
						
							|  |  |  | 				Categories.create({ | 
					
						
							|  |  |  | 					name: 'Test Category 2', | 
					
						
							|  |  |  | 					description: 'Test category created by testing script', | 
					
						
							|  |  |  | 				}), | 
					
						
							|  |  |  | 				Topics.post({ | 
					
						
							|  |  |  | 					uid: posterUid, | 
					
						
							|  |  |  | 					cid: categoryObj.cid, | 
					
						
							|  |  |  | 					title: 'Test Topic Title', | 
					
						
							|  |  |  | 					content: 'The content of test topic', | 
					
						
							|  |  |  | 				}), | 
					
						
							|  |  |  | 			]); | 
					
						
							|  |  |  | 			moveCid = category.cid; | 
					
						
							|  |  |  | 			moveTid = topic.topicData.tid; | 
					
						
							|  |  |  | 			await Topics.reply({ uid: posterUid, content: 'test post', tid: moveTid }); | 
					
						
							| 
									
										
										
										
											2016-10-11 16:06:42 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should move posts from one category to another', (done) => { | 
					
						
							|  |  |  | 			Categories.moveRecentReplies(moveTid, categoryObj.cid, moveCid, (err) => { | 
					
						
							| 
									
										
										
										
											2016-10-11 16:06:42 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				db.getSortedSetRange(`cid:${categoryObj.cid}:pids`, 0, -1, (err, pids) => { | 
					
						
							| 
									
										
										
										
											2016-10-11 16:06:42 +03:00
										 |  |  | 					assert.ifError(err); | 
					
						
							|  |  |  | 					assert.equal(pids.length, 0); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 					db.getSortedSetRange(`cid:${moveCid}:pids`, 0, -1, (err, pids) => { | 
					
						
							| 
									
										
										
										
											2016-10-11 16:06:42 +03:00
										 |  |  | 						assert.ifError(err); | 
					
						
							|  |  |  | 						assert.equal(pids.length, 2); | 
					
						
							|  |  |  | 						done(); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:58:56 -05:00
										 |  |  | 	describe('api/socket methods', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		const socketCategories = require('../src/socket.io/categories'); | 
					
						
							| 
									
										
										
										
											2021-12-06 21:58:56 -05:00
										 |  |  | 		const apiCategories = require('../src/api/categories'); | 
					
						
							| 
									
										
										
										
											2021-03-13 22:54:32 -05:00
										 |  |  | 		before(async () => { | 
					
						
							|  |  |  | 			await Topics.post({ | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				uid: posterUid, | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				title: 'Test Topic Title', | 
					
						
							|  |  |  | 				content: 'The content of test topic', | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				tags: ['nodebb'], | 
					
						
							| 
									
										
										
										
											2021-03-13 22:54:32 -05:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 			const data = await Topics.post({ | 
					
						
							|  |  |  | 				uid: posterUid, | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				title: 'will delete', | 
					
						
							|  |  |  | 				content: 'The content of deleted topic', | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			await Topics.delete(data.topicData.tid, adminUid); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should get recent replies in category', (done) => { | 
					
						
							|  |  |  | 			socketCategories.getRecentReplies({ uid: posterUid }, categoryObj.cid, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data)); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should get categories', (done) => { | 
					
						
							|  |  |  | 			socketCategories.get({ uid: posterUid }, {}, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data)); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should get watched categories', (done) => { | 
					
						
							|  |  |  | 			socketCategories.getWatchedCategories({ uid: posterUid }, {}, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data)); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load more topics', (done) => { | 
					
						
							| 
									
										
										
										
											2017-06-06 16:40:32 -04:00
										 |  |  | 			socketCategories.loadMore({ uid: posterUid }, { | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				after: 0, | 
					
						
							|  |  |  | 				query: { | 
					
						
							|  |  |  | 					author: 'poster', | 
					
						
							|  |  |  | 					tag: 'nodebb', | 
					
						
							|  |  |  | 				}, | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data.topics)); | 
					
						
							|  |  |  | 				assert.equal(data.topics[0].user.username, 'poster'); | 
					
						
							|  |  |  | 				assert.equal(data.topics[0].tags[0].value, 'nodebb'); | 
					
						
							|  |  |  | 				assert.equal(data.topics[0].category.cid, categoryObj.cid); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-13 22:54:32 -05:00
										 |  |  | 		it('should not show deleted topic titles', async () => { | 
					
						
							|  |  |  | 			const data = await socketCategories.loadMore({ uid: 0 }, { | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				after: 0, | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			assert.deepStrictEqual( | 
					
						
							|  |  |  | 				data.topics.map(t => t.title), | 
					
						
							| 
									
										
										
										
											2023-10-05 12:48:50 -04:00
										 |  |  | 				['[[topic:topic-is-deleted]]', 'Test Topic Title', 'Test Topic Title'], | 
					
						
							| 
									
										
										
										
											2021-03-13 22:54:32 -05:00
										 |  |  | 			); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load topic count', (done) => { | 
					
						
							|  |  |  | 			socketCategories.getTopicCount({ uid: posterUid }, categoryObj.cid, (err, topicCount) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-03-13 22:54:32 -05:00
										 |  |  | 				assert.strictEqual(topicCount, 3); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load category by privilege', (done) => { | 
					
						
							|  |  |  | 			socketCategories.getCategoriesByPrivilege({ uid: posterUid }, 'find', (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data)); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should get move categories', (done) => { | 
					
						
							|  |  |  | 			socketCategories.getMoveCategories({ uid: posterUid }, {}, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data)); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should ignore category', (done) => { | 
					
						
							|  |  |  | 			socketCategories.ignore({ uid: posterUid }, { cid: categoryObj.cid }, (err) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				Categories.isIgnored([categoryObj.cid], posterUid, (err, isIgnored) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 					assert.ifError(err); | 
					
						
							|  |  |  | 					assert.equal(isIgnored[0], true); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 					Categories.getIgnorers(categoryObj.cid, 0, -1, (err, ignorers) => { | 
					
						
							| 
									
										
										
										
											2018-12-14 16:24:17 -05:00
										 |  |  | 						assert.ifError(err); | 
					
						
							|  |  |  | 						assert.deepEqual(ignorers, [posterUid]); | 
					
						
							|  |  |  | 						done(); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should watch category', (done) => { | 
					
						
							|  |  |  | 			socketCategories.watch({ uid: posterUid }, { cid: categoryObj.cid }, (err) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				Categories.isIgnored([categoryObj.cid], posterUid, (err, isIgnored) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 					assert.ifError(err); | 
					
						
							|  |  |  | 					assert.equal(isIgnored[0], false); | 
					
						
							|  |  |  | 					done(); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should error if watch state does not exist', (done) => { | 
					
						
							|  |  |  | 			socketCategories.setWatchState({ uid: posterUid }, { cid: categoryObj.cid, state: 'invalid-state' }, (err) => { | 
					
						
							| 
									
										
										
										
											2018-12-14 16:24:17 -05:00
										 |  |  | 				assert.equal(err.message, '[[error:invalid-watch-state]]'); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should check if user is moderator', (done) => { | 
					
						
							|  |  |  | 			socketCategories.isModerator({ uid: posterUid }, {}, (err, isModerator) => { | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(!isModerator); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:58:56 -05:00
										 |  |  | 		it('should get category data', async () => { | 
					
						
							|  |  |  | 			const data = await apiCategories.get({ uid: posterUid }, { cid: categoryObj.cid }); | 
					
						
							|  |  |  | 			assert.equal(categoryObj.cid, data.cid); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 20:22:09 -05:00
										 |  |  | 	describe('admin api/socket methods', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		const socketCategories = require('../src/socket.io/admin/categories'); | 
					
						
							| 
									
										
										
										
											2021-12-06 20:14:44 -05:00
										 |  |  | 		const apiCategories = require('../src/api/categories'); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		let cid; | 
					
						
							| 
									
										
										
										
											2021-12-06 20:14:44 -05:00
										 |  |  | 		before(async () => { | 
					
						
							|  |  |  | 			const category = await apiCategories.create({ uid: adminUid }, { | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 				name: 'update name', | 
					
						
							|  |  |  | 				description: 'update description', | 
					
						
							|  |  |  | 				parentCid: categoryObj.cid, | 
					
						
							|  |  |  | 				icon: 'fa-check', | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				order: '5', | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2021-12-06 20:14:44 -05:00
										 |  |  | 			cid = category.cid; | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 		it('should return error with invalid data', async () => { | 
					
						
							|  |  |  | 			let err; | 
					
						
							|  |  |  | 			try { | 
					
						
							|  |  |  | 				await apiCategories.update({ uid: adminUid }, null); | 
					
						
							|  |  |  | 			} catch (_err) { | 
					
						
							|  |  |  | 				err = _err; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			assert.strictEqual(err.message, '[[error:invalid-data]]'); | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 		it('should error if you try to set parent as self', async () => { | 
					
						
							| 
									
										
											  
											
												Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
											
										 
											2023-03-17 11:58:31 -04:00
										 |  |  | 			const updateData = { | 
					
						
							|  |  |  | 				cid, | 
					
						
							|  |  |  | 				values: { | 
					
						
							|  |  |  | 					parentCid: cid, | 
					
						
							|  |  |  | 				}, | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 			let err; | 
					
						
							|  |  |  | 			try { | 
					
						
							|  |  |  | 				await apiCategories.update({ uid: adminUid }, updateData); | 
					
						
							|  |  |  | 			} catch (_err) { | 
					
						
							|  |  |  | 				err = _err; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			assert.strictEqual(err.message, '[[error:cant-set-self-as-parent]]'); | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 		it('should error if you try to set child as parent', async () => { | 
					
						
							|  |  |  | 			const parentCategory = await Categories.create({ name: 'parent 1', description: 'poor parent' }); | 
					
						
							|  |  |  | 			const parentCid = parentCategory.cid; | 
					
						
							|  |  |  | 			const childCategory = await Categories.create({ name: 'child1', description: 'wanna be parent', parentCid: parentCid }); | 
					
						
							|  |  |  | 			const child1Cid = childCategory.cid; | 
					
						
							| 
									
										
											  
											
												Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
											
										 
											2023-03-17 11:58:31 -04:00
										 |  |  | 			const updateData = { | 
					
						
							|  |  |  | 				cid: parentCid, | 
					
						
							|  |  |  | 				values: { | 
					
						
							|  |  |  | 					parentCid: child1Cid, | 
					
						
							|  |  |  | 				}, | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 			}; | 
					
						
							|  |  |  | 			let err; | 
					
						
							|  |  |  | 			try { | 
					
						
							|  |  |  | 				await apiCategories.update({ uid: adminUid }, updateData); | 
					
						
							|  |  |  | 			} catch (_err) { | 
					
						
							|  |  |  | 				err = _err; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			assert.strictEqual(err.message, '[[error:cant-set-child-as-parent]]'); | 
					
						
							| 
									
										
										
										
											2018-11-06 13:34:29 -05:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 		it('should update category data', async () => { | 
					
						
							| 
									
										
											  
											
												Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
											
										 
											2023-03-17 11:58:31 -04:00
										 |  |  | 			const updateData = { | 
					
						
							|  |  |  | 				cid, | 
					
						
							|  |  |  | 				values: { | 
					
						
							|  |  |  | 					name: 'new name', | 
					
						
							|  |  |  | 					description: 'new description', | 
					
						
							|  |  |  | 					parentCid: 0, | 
					
						
							|  |  |  | 					order: 3, | 
					
						
							|  |  |  | 					icon: 'fa-hammer', | 
					
						
							|  |  |  | 				}, | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2021-12-06 20:34:33 -05:00
										 |  |  | 			await apiCategories.update({ uid: adminUid }, updateData); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			const data = await Categories.getCategoryData(cid); | 
					
						
							| 
									
										
											  
											
												Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
											
										 
											2023-03-17 11:58:31 -04:00
										 |  |  | 			assert.equal(data.name, updateData.values.name); | 
					
						
							|  |  |  | 			assert.equal(data.description, updateData.values.description); | 
					
						
							|  |  |  | 			assert.equal(data.parentCid, updateData.values.parentCid); | 
					
						
							|  |  |  | 			assert.equal(data.order, updateData.values.order); | 
					
						
							|  |  |  | 			assert.equal(data.icon, updateData.values.icon); | 
					
						
							| 
									
										
										
										
											2016-11-23 13:38:20 +03:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-11-25 17:46:29 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-03 09:40:54 -04:00
										 |  |  | 		it('should properly order categories', async () => { | 
					
						
							|  |  |  | 			const p1 = await Categories.create({ name: 'p1', description: 'd', parentCid: 0, order: 1 }); | 
					
						
							|  |  |  | 			const c1 = await Categories.create({ name: 'c1', description: 'd1', parentCid: p1.cid, order: 1 }); | 
					
						
							|  |  |  | 			const c2 = await Categories.create({ name: 'c2', description: 'd2', parentCid: p1.cid, order: 2 }); | 
					
						
							|  |  |  | 			const c3 = await Categories.create({ name: 'c3', description: 'd3', parentCid: p1.cid, order: 3 }); | 
					
						
							|  |  |  | 			// move c1 to second place
 | 
					
						
							| 
									
										
											  
											
												Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
											
										 
											2023-03-17 11:58:31 -04:00
										 |  |  | 			await apiCategories.update({ uid: adminUid }, { cid: c1.cid, values: { order: 2 } }); | 
					
						
							| 
									
										
										
										
											2022-10-03 09:40:54 -04:00
										 |  |  | 			let cids = await db.getSortedSetRange(`cid:${p1.cid}:children`, 0, -1); | 
					
						
							|  |  |  | 			assert.deepStrictEqual(cids.map(Number), [c2.cid, c1.cid, c3.cid]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// move c3 to front
 | 
					
						
							| 
									
										
											  
											
												Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
											
										 
											2023-03-17 11:58:31 -04:00
										 |  |  | 			await apiCategories.update({ uid: adminUid }, { cid: c3.cid, values: { order: 1 } }); | 
					
						
							| 
									
										
										
										
											2022-10-03 09:40:54 -04:00
										 |  |  | 			cids = await db.getSortedSetRange(`cid:${p1.cid}:children`, 0, -1); | 
					
						
							|  |  |  | 			assert.deepStrictEqual(cids.map(Number), [c3.cid, c2.cid, c1.cid]); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-04 11:45:06 -04:00
										 |  |  | 		it('should not remove category from parent if parent is set again to same category', async () => { | 
					
						
							|  |  |  | 			const parentCat = await Categories.create({ name: 'parent', description: 'poor parent' }); | 
					
						
							|  |  |  | 			const updateData = {}; | 
					
						
							|  |  |  | 			updateData[cid] = { | 
					
						
							|  |  |  | 				parentCid: parentCat.cid, | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 			await Categories.update(updateData); | 
					
						
							|  |  |  | 			let data = await Categories.getCategoryData(cid); | 
					
						
							|  |  |  | 			assert.equal(data.parentCid, updateData[cid].parentCid); | 
					
						
							|  |  |  | 			let childrenCids = await db.getSortedSetRange(`cid:${parentCat.cid}:children`, 0, -1); | 
					
						
							|  |  |  | 			assert(childrenCids.includes(String(cid))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// update again to same parent
 | 
					
						
							|  |  |  | 			await Categories.update(updateData); | 
					
						
							|  |  |  | 			data = await Categories.getCategoryData(cid); | 
					
						
							|  |  |  | 			assert.equal(data.parentCid, updateData[cid].parentCid); | 
					
						
							|  |  |  | 			childrenCids = await db.getSortedSetRange(`cid:${parentCat.cid}:children`, 0, -1); | 
					
						
							|  |  |  | 			assert(childrenCids.includes(String(cid))); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 20:22:09 -05:00
										 |  |  | 		it('should purge category', async () => { | 
					
						
							|  |  |  | 			const category = await Categories.create({ | 
					
						
							| 
									
										
										
										
											2016-11-25 17:46:29 +03:00
										 |  |  | 				name: 'purge me', | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				description: 'update description', | 
					
						
							| 
									
										
										
										
											2016-11-25 17:46:29 +03:00
										 |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2021-12-06 20:22:09 -05:00
										 |  |  | 			await Topics.post({ | 
					
						
							|  |  |  | 				uid: posterUid, | 
					
						
							|  |  |  | 				cid: category.cid, | 
					
						
							|  |  |  | 				title: 'Test Topic Title', | 
					
						
							|  |  |  | 				content: 'The content of test topic', | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			await apiCategories.delete({ uid: adminUid }, { cid: category.cid }); | 
					
						
							|  |  |  | 			const data = await Categories.getCategoryById(category.cid); | 
					
						
							|  |  |  | 			assert.strictEqual(data, null); | 
					
						
							| 
									
										
										
										
											2016-11-25 17:46:29 +03:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should get all category names', (done) => { | 
					
						
							|  |  |  | 			socketCategories.getNames({ uid: adminUid }, {}, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(Array.isArray(data)); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:47:47 -05:00
										 |  |  | 		it('should give privilege', async () => { | 
					
						
							|  |  |  | 			await apiCategories.setPrivilege({ uid: adminUid }, { cid: categoryObj.cid, privilege: ['groups:topics:delete'], set: true, member: 'registered-users' }); | 
					
						
							|  |  |  | 			const canDeleteTopics = await privileges.categories.can('topics:delete', categoryObj.cid, posterUid); | 
					
						
							|  |  |  | 			assert(canDeleteTopics); | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:47:47 -05:00
										 |  |  | 		it('should remove privilege', async () => { | 
					
						
							|  |  |  | 			await apiCategories.setPrivilege({ uid: adminUid }, { cid: categoryObj.cid, privilege: 'groups:topics:delete', set: false, member: 'registered-users' }); | 
					
						
							|  |  |  | 			const canDeleteTopics = await privileges.categories.can('topics:delete', categoryObj.cid, posterUid); | 
					
						
							|  |  |  | 			assert(!canDeleteTopics); | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:47:47 -05:00
										 |  |  | 		it('should get privilege settings', async () => { | 
					
						
							|  |  |  | 			const data = await apiCategories.getPrivileges({ uid: adminUid }, categoryObj.cid); | 
					
						
							| 
									
										
										
										
											2025-05-06 15:13:29 -04:00
										 |  |  | 			assert(data.labelData); | 
					
						
							| 
									
										
										
										
											2021-12-06 21:47:47 -05:00
										 |  |  | 			assert(data.keys.users); | 
					
						
							|  |  |  | 			assert(data.keys.groups); | 
					
						
							|  |  |  | 			assert(data.users); | 
					
						
							|  |  |  | 			assert(data.groups); | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:47:47 -05:00
										 |  |  | 		it('should copy privileges to children', async () => { | 
					
						
							|  |  |  | 			const parentCategory = await Categories.create({ name: 'parent' }); | 
					
						
							|  |  |  | 			const parentCid = parentCategory.cid; | 
					
						
							|  |  |  | 			const child1 = await Categories.create({ name: 'child1', parentCid: parentCid }); | 
					
						
							|  |  |  | 			const child2 = await Categories.create({ name: 'child2', parentCid: child1.cid }); | 
					
						
							|  |  |  | 			await apiCategories.setPrivilege({ uid: adminUid }, { | 
					
						
							|  |  |  | 				cid: parentCid, | 
					
						
							|  |  |  | 				privilege: 'groups:topics:delete', | 
					
						
							|  |  |  | 				set: true, | 
					
						
							|  |  |  | 				member: 'registered-users', | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			await socketCategories.copyPrivilegesToChildren({ uid: adminUid }, { cid: parentCid, group: '' }); | 
					
						
							|  |  |  | 			const canDelete = await privileges.categories.can('topics:delete', child2.cid, posterUid); | 
					
						
							|  |  |  | 			assert(canDelete); | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-22 11:44:32 -04:00
										 |  |  | 		it('should create category with settings from', async () => { | 
					
						
							|  |  |  | 			const category = await Categories.create({ name: 'copy from', description: 'copy me' }); | 
					
						
							|  |  |  | 			const parentCid = category.cid; | 
					
						
							|  |  |  | 			const childCategory = await Categories.create({ name: 'child1', description: 'will be gone', cloneFromCid: parentCid }); | 
					
						
							|  |  |  | 			assert.equal(childCategory.description, 'copy me'); | 
					
						
							| 
									
										
										
										
											2018-10-22 21:58:34 -04:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-22 11:44:32 -04:00
										 |  |  | 		it('should copy settings from', async () => { | 
					
						
							|  |  |  | 			const category = await Categories.create({ name: 'parent', description: 'copy me' }); | 
					
						
							|  |  |  | 			const parentCid = category.cid; | 
					
						
							|  |  |  | 			const childCategory = await Categories.create({ name: 'child1' }); | 
					
						
							|  |  |  | 			const child1Cid = childCategory.cid; | 
					
						
							|  |  |  | 			const destinationCategory = await socketCategories.copySettingsFrom( | 
					
						
							|  |  |  | 				{ uid: adminUid }, | 
					
						
							|  |  |  | 				{ fromCid: parentCid, toCid: child1Cid, copyParent: true }, | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 			const description = await Categories.getCategoryField(child1Cid, 'description'); | 
					
						
							|  |  |  | 			assert.equal(description, 'copy me'); | 
					
						
							| 
									
										
										
										
											2016-12-02 18:08:08 +03:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:47:47 -05:00
										 |  |  | 		it('should copy privileges from another category', async () => { | 
					
						
							|  |  |  | 			const parent = await Categories.create({ name: 'parent', description: 'copy me' }); | 
					
						
							|  |  |  | 			const parentCid = parent.cid; | 
					
						
							|  |  |  | 			const child1 = await Categories.create({ name: 'child1' }); | 
					
						
							|  |  |  | 			await apiCategories.setPrivilege({ uid: adminUid }, { | 
					
						
							|  |  |  | 				cid: parentCid, | 
					
						
							|  |  |  | 				privilege: 'groups:topics:delete', | 
					
						
							|  |  |  | 				set: true, | 
					
						
							|  |  |  | 				member: 'registered-users', | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			await socketCategories.copyPrivilegesFrom({ uid: adminUid }, { fromCid: parentCid, toCid: child1.cid }); | 
					
						
							|  |  |  | 			const canDelete = await privileges.categories.can('topics:delete', child1.cid, posterUid); | 
					
						
							|  |  |  | 			assert(canDelete); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		it('should copy privileges from another category for a single group', async () => { | 
					
						
							|  |  |  | 			const parent = await Categories.create({ name: 'parent', description: 'copy me' }); | 
					
						
							|  |  |  | 			const parentCid = parent.cid; | 
					
						
							|  |  |  | 			const child1 = await Categories.create({ name: 'child1' }); | 
					
						
							|  |  |  | 			await apiCategories.setPrivilege({ uid: adminUid }, { | 
					
						
							|  |  |  | 				cid: parentCid, | 
					
						
							|  |  |  | 				privilege: 'groups:topics:delete', | 
					
						
							|  |  |  | 				set: true, | 
					
						
							|  |  |  | 				member: 'registered-users', | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			await socketCategories.copyPrivilegesFrom({ uid: adminUid }, { fromCid: parentCid, toCid: child1.cid, group: 'registered-users' }); | 
					
						
							|  |  |  | 			const canDelete = await privileges.categories.can('topics:delete', child1.cid, 0); | 
					
						
							|  |  |  | 			assert(!canDelete); | 
					
						
							| 
									
										
										
										
											2019-05-15 20:56:23 -04:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should get active users', (done) => { | 
					
						
							| 
									
										
										
										
											2016-12-02 16:10:07 +03:00
										 |  |  | 		Categories.create({ | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 			name: 'test', | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		}, (err, category) => { | 
					
						
							| 
									
										
										
										
											2016-12-02 16:10:07 +03:00
										 |  |  | 			assert.ifError(err); | 
					
						
							|  |  |  | 			Topics.post({ | 
					
						
							|  |  |  | 				uid: posterUid, | 
					
						
							|  |  |  | 				cid: category.cid, | 
					
						
							|  |  |  | 				title: 'Test Topic Title', | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				content: 'The content of test topic', | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err) => { | 
					
						
							| 
									
										
										
										
											2016-12-02 16:10:07 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				Categories.getActiveUsers(category.cid, (err, uids) => { | 
					
						
							| 
									
										
										
										
											2016-12-02 16:10:07 +03:00
										 |  |  | 					assert.ifError(err); | 
					
						
							|  |  |  | 					assert.equal(uids[0], posterUid); | 
					
						
							|  |  |  | 					done(); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	describe('tag whitelist', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		let cid; | 
					
						
							|  |  |  | 		const socketTopics = require('../src/socket.io/topics'); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		before((done) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 			Categories.create({ | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				name: 'test', | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, category) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				cid = category.cid; | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should error if data is invalid', (done) => { | 
					
						
							|  |  |  | 			socketTopics.isTagAllowed({ uid: posterUid }, null, (err) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.equal(err.message, '[[error:invalid-data]]'); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should return true if category whitelist is empty', (done) => { | 
					
						
							|  |  |  | 			socketTopics.isTagAllowed({ uid: posterUid }, { tag: 'notallowed', cid: cid }, (err, allowed) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(allowed); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should add tags to category whitelist', (done) => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 			const data = {}; | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 			data[cid] = { | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				tagWhitelist: 'nodebb,jquery,javascript', | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			Categories.update(data, (err) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 				db.getSortedSetRange(`cid:${cid}:tag:whitelist`, 0, -1, (err, tagWhitelist) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 					assert.ifError(err); | 
					
						
							|  |  |  | 					assert.deepEqual(['nodebb', 'jquery', 'javascript'], tagWhitelist); | 
					
						
							|  |  |  | 					done(); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should return false if category whitelist does not have tag', (done) => { | 
					
						
							|  |  |  | 			socketTopics.isTagAllowed({ uid: posterUid }, { tag: 'notallowed', cid: cid }, (err, allowed) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(!allowed); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should return true if category whitelist has tag', (done) => { | 
					
						
							|  |  |  | 			socketTopics.isTagAllowed({ uid: posterUid }, { tag: 'nodebb', cid: cid }, (err, allowed) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(allowed); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should post a topic with only allowed tags', (done) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 			Topics.post({ | 
					
						
							|  |  |  | 				uid: posterUid, | 
					
						
							|  |  |  | 				cid: cid, | 
					
						
							|  |  |  | 				title: 'Test Topic Title', | 
					
						
							|  |  |  | 				content: 'The content of test topic', | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				tags: ['nodebb', 'jquery', 'notallowed'], | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, data) => { | 
					
						
							| 
									
										
										
										
											2016-12-09 18:53:08 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.equal(data.topicData.tags.length, 2); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2016-12-02 16:10:07 +03:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-11-21 13:47:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	describe('privileges', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		const privileges = require('../src/privileges'); | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should return empty array if uids is empty array', (done) => { | 
					
						
							|  |  |  | 			privileges.categories.filterUids('find', categoryObj.cid, [], (err, uids) => { | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.equal(uids.length, 0); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should filter uids by privilege', (done) => { | 
					
						
							|  |  |  | 			privileges.categories.filterUids('find', categoryObj.cid, [1, 2, 3, 4], (err, uids) => { | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.deepEqual(uids, [1, 2]); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load category user privileges', (done) => { | 
					
						
							|  |  |  | 			privileges.categories.userPrivileges(categoryObj.cid, 1, (err, data) => { | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.deepEqual(data, { | 
					
						
							|  |  |  | 					find: false, | 
					
						
							|  |  |  | 					'posts:delete': false, | 
					
						
							|  |  |  | 					read: false, | 
					
						
							|  |  |  | 					'topics:reply': false, | 
					
						
							|  |  |  | 					'topics:read': false, | 
					
						
							|  |  |  | 					'topics:create': false, | 
					
						
							| 
									
										
										
										
											2017-06-16 14:25:40 -04:00
										 |  |  | 					'topics:tag': false, | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 					'topics:delete': false, | 
					
						
							| 
									
										
										
										
											2021-03-24 21:28:02 +03:00
										 |  |  | 					'topics:schedule': false, | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 					'posts:edit': false, | 
					
						
							| 
									
										
										
										
											2018-06-07 12:40:20 -04:00
										 |  |  | 					'posts:history': false, | 
					
						
							| 
									
										
										
										
											2018-01-09 14:33:23 -05:00
										 |  |  | 					'posts:upvote': false, | 
					
						
							|  |  |  | 					'posts:downvote': false, | 
					
						
							| 
									
										
										
										
											2017-06-15 14:02:51 -04:00
										 |  |  | 					purge: false, | 
					
						
							| 
									
										
										
										
											2018-06-08 16:17:17 -04:00
										 |  |  | 					'posts:view_deleted': false, | 
					
						
							| 
									
										
										
										
											2017-06-15 14:02:51 -04:00
										 |  |  | 					moderate: false, | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load global user privileges', (done) => { | 
					
						
							|  |  |  | 			privileges.global.userPrivileges(1, (err, data) => { | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.deepEqual(data, { | 
					
						
							| 
									
										
										
										
											2018-05-25 12:09:27 -04:00
										 |  |  | 					ban: false, | 
					
						
							| 
									
										
										
										
											2022-03-11 23:45:01 -05:00
										 |  |  | 					mute: false, | 
					
						
							| 
									
										
										
										
											2020-11-16 22:47:23 +03:00
										 |  |  | 					invite: false, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 					chat: false, | 
					
						
							| 
									
										
										
										
											2023-10-17 13:19:25 -04:00
										 |  |  | 					'chat:privileged': false, | 
					
						
							| 
									
										
										
										
											2018-05-28 11:29:37 -04:00
										 |  |  | 					'search:content': false, | 
					
						
							|  |  |  | 					'search:users': false, | 
					
						
							|  |  |  | 					'search:tags': false, | 
					
						
							| 
									
										
										
										
											2019-09-17 18:02:52 +00:00
										 |  |  | 					'view:users:info': false, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 					'upload:post:image': false, | 
					
						
							|  |  |  | 					'upload:post:file': false, | 
					
						
							| 
									
										
										
										
											2018-02-28 17:38:31 -05:00
										 |  |  | 					signature: false, | 
					
						
							| 
									
										
										
										
											2018-09-29 06:49:41 -04:00
										 |  |  | 					'local:login': false, | 
					
						
							| 
									
										
										
										
											2019-02-04 14:16:47 -05:00
										 |  |  | 					'group:create': false, | 
					
						
							| 
									
										
										
										
											2019-02-05 12:08:18 -05:00
										 |  |  | 					'view:users': false, | 
					
						
							|  |  |  | 					'view:tags': false, | 
					
						
							|  |  |  | 					'view:groups': false, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load category group privileges', (done) => { | 
					
						
							|  |  |  | 			privileges.categories.groupPrivileges(categoryObj.cid, 'registered-users', (err, data) => { | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.deepEqual(data, { | 
					
						
							|  |  |  | 					'groups:find': true, | 
					
						
							|  |  |  | 					'groups:posts:edit': true, | 
					
						
							| 
									
										
										
										
											2018-06-07 12:40:20 -04:00
										 |  |  | 					'groups:posts:history': true, | 
					
						
							| 
									
										
										
										
											2018-01-09 14:33:23 -05:00
										 |  |  | 					'groups:posts:upvote': true, | 
					
						
							|  |  |  | 					'groups:posts:downvote': true, | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 					'groups:topics:delete': false, | 
					
						
							|  |  |  | 					'groups:topics:create': true, | 
					
						
							|  |  |  | 					'groups:topics:reply': true, | 
					
						
							| 
									
										
										
										
											2017-06-16 14:25:40 -04:00
										 |  |  | 					'groups:topics:tag': true, | 
					
						
							| 
									
										
										
										
											2021-03-24 21:28:02 +03:00
										 |  |  | 					'groups:topics:schedule': false, | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 					'groups:posts:delete': true, | 
					
						
							|  |  |  | 					'groups:read': true, | 
					
						
							|  |  |  | 					'groups:topics:read': true, | 
					
						
							| 
									
										
										
										
											2017-06-15 14:02:51 -04:00
										 |  |  | 					'groups:purge': false, | 
					
						
							| 
									
										
										
										
											2018-06-08 16:17:17 -04:00
										 |  |  | 					'groups:posts:view_deleted': false, | 
					
						
							| 
									
										
										
										
											2017-06-15 14:02:51 -04:00
										 |  |  | 					'groups:moderate': false, | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should load global group privileges', (done) => { | 
					
						
							|  |  |  | 			privileges.global.groupPrivileges('registered-users', (err, data) => { | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.deepEqual(data, { | 
					
						
							| 
									
										
										
										
											2018-05-25 12:09:27 -04:00
										 |  |  | 					'groups:ban': false, | 
					
						
							| 
									
										
										
										
											2022-03-11 23:45:01 -05:00
										 |  |  | 					'groups:mute': false, | 
					
						
							| 
									
										
										
										
											2020-11-16 22:47:23 +03:00
										 |  |  | 					'groups:invite': false, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 					'groups:chat': true, | 
					
						
							| 
									
										
										
										
											2023-10-17 13:19:25 -04:00
										 |  |  | 					'groups:chat:privileged': false, | 
					
						
							| 
									
										
										
										
											2018-05-28 11:29:37 -04:00
										 |  |  | 					'groups:search:content': true, | 
					
						
							|  |  |  | 					'groups:search:users': true, | 
					
						
							|  |  |  | 					'groups:search:tags': true, | 
					
						
							| 
									
										
										
										
											2019-02-05 12:08:18 -05:00
										 |  |  | 					'groups:view:users': true, | 
					
						
							| 
									
										
										
										
											2019-09-17 18:02:52 +00:00
										 |  |  | 					'groups:view:users:info': false, | 
					
						
							| 
									
										
										
										
											2019-02-05 12:08:18 -05:00
										 |  |  | 					'groups:view:tags': true, | 
					
						
							|  |  |  | 					'groups:view:groups': true, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 					'groups:upload:post:image': true, | 
					
						
							|  |  |  | 					'groups:upload:post:file': false, | 
					
						
							| 
									
										
										
										
											2018-02-28 17:38:31 -05:00
										 |  |  | 					'groups:signature': true, | 
					
						
							| 
									
										
										
										
											2018-09-29 06:49:41 -04:00
										 |  |  | 					'groups:local:login': true, | 
					
						
							| 
									
										
										
										
											2019-02-04 14:16:47 -05:00
										 |  |  | 					'groups:group:create': false, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should return false if cid is falsy', (done) => { | 
					
						
							|  |  |  | 			privileges.categories.isUserAllowedTo('find', null, adminUid, (err, isAllowed) => { | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.equal(isAllowed, false); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2019-01-04 13:27:31 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-21 14:34:01 -05:00
										 |  |  | 		describe('Categories.getModeratorUids', () => { | 
					
						
							| 
									
										
										
										
											2023-01-18 15:08:35 -05:00
										 |  |  | 			let cid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			before(async () => { | 
					
						
							|  |  |  | 				({ cid } = await Categories.create({ name: 'foobar' })); | 
					
						
							|  |  |  | 				await groups.create({ name: 'testGroup' }); | 
					
						
							|  |  |  | 				await groups.join(`cid:${cid}:privileges:groups:moderate`, 'testGroup'); | 
					
						
							|  |  |  | 				await groups.join('testGroup', 1); | 
					
						
							| 
									
										
										
										
											2019-01-04 13:27:31 -05:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			it('should retrieve all users with moderator bit in category privilege', (done) => { | 
					
						
							| 
									
										
										
										
											2023-01-18 15:08:35 -05:00
										 |  |  | 				Categories.getModeratorUids([cid, 2], (err, uids) => { | 
					
						
							| 
									
										
										
										
											2019-01-04 13:27:31 -05:00
										 |  |  | 					assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2019-05-30 20:12:04 -04:00
										 |  |  | 					assert.strictEqual(uids.length, 2); | 
					
						
							| 
									
										
										
										
											2019-05-30 19:30:47 -04:00
										 |  |  | 					assert(uids[0].includes('1')); | 
					
						
							| 
									
										
										
										
											2019-05-30 20:12:04 -04:00
										 |  |  | 					assert.strictEqual(uids[1].length, 0); | 
					
						
							| 
									
										
										
										
											2019-01-04 13:27:31 -05:00
										 |  |  | 					done(); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-22 11:44:32 -04:00
										 |  |  | 			it('should not fail when there are multiple groups', async () => { | 
					
						
							|  |  |  | 				await groups.create({ name: 'testGroup2' }); | 
					
						
							|  |  |  | 				await groups.join('cid:1:privileges:groups:moderate', 'testGroup2'); | 
					
						
							|  |  |  | 				await groups.join('testGroup2', 1); | 
					
						
							|  |  |  | 				const uids = await Categories.getModeratorUids([cid, 2]); | 
					
						
							|  |  |  | 				assert(uids[0].includes('1')); | 
					
						
							| 
									
										
										
										
											2019-05-29 15:44:33 -04:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-18 15:08:35 -05:00
										 |  |  | 			it('should not return moderators of disabled categories', async () => { | 
					
						
							|  |  |  | 				const payload = {}; | 
					
						
							|  |  |  | 				payload[cid] = { disabled: 1 }; | 
					
						
							|  |  |  | 				await Categories.update(payload); | 
					
						
							| 
									
										
										
										
											2023-01-21 14:34:01 -05:00
										 |  |  | 				const uids = await Categories.getModeratorUids([cid, 2]); | 
					
						
							| 
									
										
										
										
											2023-01-18 15:08:35 -05:00
										 |  |  | 				assert(!uids[0].includes('1')); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-22 11:44:32 -04:00
										 |  |  | 			after(async () => { | 
					
						
							|  |  |  | 				await groups.leave(`cid:${cid}:privileges:groups:moderate`, 'testGroup'); | 
					
						
							|  |  |  | 				await groups.leave(`cid:${cid}:privileges:groups:moderate`, 'testGroup2'); | 
					
						
							|  |  |  | 				await groups.destroy('testGroup'); | 
					
						
							|  |  |  | 				await groups.destroy('testGroup2'); | 
					
						
							| 
									
										
										
										
											2019-01-04 13:27:31 -05:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-03-03 21:04:01 +03:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-06-06 16:40:32 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	describe('getTopicIds', () => { | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | 		const plugins = require('../src/plugins'); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		it('should get topic ids with filter', (done) => { | 
					
						
							| 
									
										
										
										
											2017-06-06 16:40:32 -04:00
										 |  |  | 			function method(data, callback) { | 
					
						
							|  |  |  | 				data.tids = [1, 2, 3]; | 
					
						
							|  |  |  | 				callback(null, data); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-27 17:36:58 -05:00
										 |  |  | 			plugins.hooks.register('my-test-plugin', { | 
					
						
							| 
									
										
										
										
											2017-06-06 16:40:32 -04:00
										 |  |  | 				hook: 'filter:categories.getTopicIds', | 
					
						
							|  |  |  | 				method: method, | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Categories.getTopicIds({ | 
					
						
							|  |  |  | 				cid: categoryObj.cid, | 
					
						
							|  |  |  | 				start: 0, | 
					
						
							|  |  |  | 				stop: 19, | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			}, (err, tids) => { | 
					
						
							| 
									
										
										
										
											2017-06-06 16:40:32 -04:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.deepEqual(tids, [1, 2, 3]); | 
					
						
							| 
									
										
										
										
											2021-01-27 17:36:58 -05:00
										 |  |  | 				plugins.hooks.unregister('my-test-plugin', 'filter:categories.getTopicIds', method); | 
					
						
							| 
									
										
										
										
											2017-06-06 16:40:32 -04:00
										 |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2020-05-12 12:18:30 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should return nested children categories', async () => { | 
					
						
							| 
									
										
										
										
											2020-05-12 12:18:30 -04:00
										 |  |  | 		const rootCategory = await Categories.create({ name: 'root' }); | 
					
						
							|  |  |  | 		const child1 = await Categories.create({ name: 'child1', parentCid: rootCategory.cid }); | 
					
						
							|  |  |  | 		const child2 = await Categories.create({ name: 'child2', parentCid: child1.cid }); | 
					
						
							|  |  |  | 		const data = await Categories.getCategoryById({ | 
					
						
							|  |  |  | 			uid: 1, | 
					
						
							|  |  |  | 			cid: rootCategory.cid, | 
					
						
							|  |  |  | 			start: 0, | 
					
						
							|  |  |  | 			stop: 19, | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		assert.strictEqual(child1.cid, data.children[0].cid); | 
					
						
							|  |  |  | 		assert.strictEqual(child2.cid, data.children[0].children[0].cid); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-01-24 00:42:34 -05:00
										 |  |  | }); |