mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	adding missing files, re: #4827
This commit is contained in:
		
							
								
								
									
										28
									
								
								src/controllers/accounts/info.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/controllers/accounts/info.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| var async = require('async'), | ||||
| 	_ = require('underscore'), | ||||
|  | ||||
| 	user = require('../../user'), | ||||
| 	helpers = require('../helpers'), | ||||
| 	accountHelpers = require('./helpers'); | ||||
|  | ||||
| var infoController = {}; | ||||
|  | ||||
| infoController.get = function(req, res, next) { | ||||
| 	accountHelpers.getBaseUser(req.params.userslug, req.uid, function(err, userData) { | ||||
| 		async.parallel({ | ||||
| 			ips: async.apply(user.getIPs, res.locals.uid, 4), | ||||
| 			history: async.apply(user.getModerationHistory, res.locals.uid) | ||||
| 		}, function(err, data) { | ||||
| 			data = _.extend(userData, data); | ||||
|  | ||||
| 			userData.title = '[[pages:account/info]]'; | ||||
| 			userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]); | ||||
|  | ||||
| 			res.render('account/info', data); | ||||
| 		}); | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| module.exports = infoController; | ||||
							
								
								
									
										73
									
								
								src/user/info.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								src/user/info.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| var async = require('async'), | ||||
| 	_ = require('underscore'); | ||||
|  | ||||
| var db = require('../database'), | ||||
| 	posts = require('../posts'), | ||||
| 	topics = require('../topics'); | ||||
|  | ||||
| module.exports = function(User) { | ||||
| 	User.getModerationHistory = function(uid, callback) { | ||||
| 		async.waterfall([ | ||||
| 			function(next) { | ||||
| 				async.parallel({ | ||||
| 					flags: async.apply(db.getSortedSetRevRangeByScoreWithScores, 'uid:' + uid + ':flag:pids', 0, 20, '+inf', '-inf'), | ||||
| 					bans: async.apply(db.getSortedSetRevRangeByScoreWithScores, 'uid:' + uid + ':bans', 0, 20, '+inf', '-inf') | ||||
| 				}, next); | ||||
| 			}, | ||||
| 			async.apply(getFlagMetadata), | ||||
| 			async.apply(formatBanData) | ||||
| 		], function(err, data) { | ||||
| 			callback(err, data); | ||||
| 		}); | ||||
| 	}; | ||||
|  | ||||
| 	function getFlagMetadata(data, callback) { | ||||
| 		// Retrieve post title & slug from flags list | ||||
| 		posts.getPostsFields(data.flags.map(function(flagObj) { | ||||
| 			return parseInt(flagObj.value, 10); | ||||
| 		}), ['tid'], function(err, postData) { | ||||
| 			if (err) { | ||||
| 				return callback(err); | ||||
| 			} | ||||
|  | ||||
| 			var tids = postData.map(function(post) { | ||||
| 				return post.tid; | ||||
| 			}); | ||||
|  | ||||
| 			topics.getTopicsFields(tids, ['title'], function(err, topicData) { | ||||
| 				data.flags = data.flags.map(function(flagObj, idx) { | ||||
| 					flagObj.pid = flagObj.value; | ||||
| 					flagObj.timestamp = flagObj.score; | ||||
| 					flagObj.timestampISO = new Date(flagObj.score).toISOString(); | ||||
| 					flagObj.timestampReadable = new Date(flagObj.score).toString(); | ||||
|  | ||||
| 					delete flagObj.value; | ||||
| 					delete flagObj.score; | ||||
|  | ||||
| 					return _.extend(flagObj, topicData[idx]); | ||||
| 				}); | ||||
|  | ||||
| 				callback(null, data); | ||||
| 			}); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	function formatBanData(data, callback) { | ||||
| 		data.bans = data.bans.map(function(banObj) { | ||||
| 			banObj.until = parseInt(banObj.value, 10); | ||||
| 			banObj.untilReadable = new Date(banObj.until).toString(); | ||||
| 			banObj.timestamp = parseInt(banObj.score, 10); | ||||
| 			banObj.timestampReadable = new Date(banObj.score).toString(); | ||||
| 			banObj.timestampISO = new Date(banObj.score).toISOString(); | ||||
|  | ||||
| 			delete banObj.value; | ||||
| 			delete banObj.score; | ||||
|  | ||||
| 			return banObj; | ||||
| 		}); | ||||
|  | ||||
| 		setImmediate(callback, null, data); | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user