Merge remote-tracking branch 'origin/master' into flagging-refactor

v1.18.x
Julian Lam 8 years ago
commit c36fe3389e

@ -2,7 +2,7 @@
"name": "nodebb", "name": "nodebb",
"license": "GPL-3.0", "license": "GPL-3.0",
"description": "NodeBB Forum", "description": "NodeBB Forum",
"version": "1.3.0", "version": "1.4.0",
"homepage": "http://www.nodebb.org", "homepage": "http://www.nodebb.org",
"repository": { "repository": {
"type": "git", "type": "git",

@ -88,3 +88,30 @@ div.categories {
} }
} }
.category {
.privilege-table {
tr > th:first-child {
min-width: 150px;
}
.privilege-table-header {
background: white;
th {
text-align: center;
border-top: 0;
text-transform: uppercase;
font-size: 9px;
}
.arrowed:after {
border-bottom: 1px dashed #ccc;
content: "";
width: 100%;
display: block;
padding-top: 5px;
}
}
}
}

@ -1,10 +1,10 @@
'use strict'; 'use strict';
var async = require('async'), var async = require('async');
var user = require('../user');
var db = require('./../database');
user = require('../user'),
db = require('./../database'),
groups = module.parent.exports;
module.exports = function (Groups) { module.exports = function (Groups) {
@ -17,7 +17,7 @@ module.exports = function (Groups) {
async.apply(db.getObjectValues, 'groupslug:groupname'), async.apply(db.getObjectValues, 'groupslug:groupname'),
function (groupNames, next) { function (groupNames, next) {
// Ephemeral groups and the registered-users groups are searchable // Ephemeral groups and the registered-users groups are searchable
groupNames = groups.getEphemeralGroups().concat(groupNames).concat('registered-users'); groupNames = Groups.getEphemeralGroups().concat(groupNames).concat('registered-users');
groupNames = groupNames.filter(function (name) { groupNames = groupNames.filter(function (name) {
return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators' && !Groups.isPrivilegeGroup(name); return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
}); });

@ -46,7 +46,7 @@ SocketUser.deleteAccount = function (socket, data, callback) {
user.deleteAccount(socket.uid, next); user.deleteAccount(socket.uid, next);
}, },
function (next) { function (next) {
socket.broadcast.emit('event:user_status_change', {uid: socket.uid, status: 'offline'}); require('./index').server.sockets.emit('event:user_status_change', {uid: socket.uid, status: 'offline'});
events.log({ events.log({
type: 'user-delete', type: 'user-delete',

@ -1,9 +1,9 @@
'use strict'; 'use strict';
var async = require('async'), var async = require('async');
plugins = require('../plugins'), var plugins = require('../plugins');
db = require('../database'); var db = require('../database');
module.exports = function (User) { module.exports = function (User) {
@ -73,25 +73,22 @@ module.exports = function (User) {
if (!parseInt(uid, 10)) { if (!parseInt(uid, 10)) {
return callback(null, []); return callback(null, []);
} }
async.waterfall([
db.getSortedSetRevRange(type + ':' + uid, start, stop, function (err, uids) { function (next) {
if (err) { db.getSortedSetRevRange(type + ':' + uid, start, stop, next);
return callback(err); },
function (uids, next) {
plugins.fireHook('filter:user.' + type, {
uids: uids,
uid: uid,
start: start,
stop: stop
}, next);
},
function (data, next) {
User.getUsers(data.uids, uid, next);
} }
], callback);
plugins.fireHook('filter:user.' + type, {
uids: uids,
uid: uid,
start: start,
stop: stop
}, function (err, data) {
if (err) {
return callback(err);
}
User.getUsers(data.uids, uid, callback);
});
});
} }
User.isFollowing = function (uid, theirid, callback) { User.isFollowing = function (uid, theirid, callback) {

@ -1,4 +1,10 @@
<table class="table table-striped table-hover privilege-table"> <table class="table table-striped privilege-table">
<tr class="privilege-table-header">
<th colspan="2"></th>
<th class="arrowed" colspan="3">Viewing Privileges</th>
<th class="arrowed" colspan="7">Posting Privileges</th>
<th class="arrowed" colspan="2">Moderation Privileges</th>
</tr><tr><!-- zebrastripe reset --></tr>
<tr> <tr>
<th colspan="2">User</th> <th colspan="2">User</th>
<!-- BEGIN privileges.labels.users --> <!-- BEGIN privileges.labels.users -->
@ -34,7 +40,13 @@
<!-- ENDIF privileges.users.length --> <!-- ENDIF privileges.users.length -->
</table> </table>
<table class="table table-striped table-hover privilege-table"> <table class="table table-striped privilege-table">
<tr class="privilege-table-header">
<th colspan="2"></th>
<th class="arrowed" colspan="3">Viewing Privileges</th>
<th class="arrowed" colspan="7">Posting Privileges</th>
<th class="arrowed" colspan="2">Moderation Privileges</th>
</tr><tr><!-- zebrastripe reset --></tr>
<tr> <tr>
<th colspan="2">Group</th> <th colspan="2">Group</th>
<!-- BEGIN privileges.labels.groups --> <!-- BEGIN privileges.labels.groups -->

@ -90,7 +90,7 @@
<form> <form>
<div class="form-group"> <div class="form-group">
<label for="timeagoCutoff">Date cut-off (in days)</label> <label for="timeagoCutoff">Date cut-off (in days)</label>
<input type="number" class="form-control" id="timeagoCutoff" data-field="timeagoCutoff" value="30" /> <input type="number" class="form-control" id="timeagoCutoff" data-field="timeagoCutoff" />
<p class="help-block"> <p class="help-block">
Dates &amp; times will be shown in a relative manner (e.g. "3 hours ago" / "5 days ago"), and localised into various Dates &amp; times will be shown in a relative manner (e.g. "3 hours ago" / "5 days ago"), and localised into various
languages. After a certain point, this text can be switched to display the localised date itself languages. After a certain point, this text can be switched to display the localised date itself

@ -785,7 +785,48 @@ describe('Controllers', function () {
done(); done();
}); });
}); });
});
describe('account follow page', function () {
var socketUser = require('../src/socket.io/user');
var uid;
before(function (done) {
user.create({username: 'follower'}, function (err, _uid) {
assert.ifError(err);
uid = _uid;
socketUser.follow({uid: uid}, {uid: fooUid}, done);
});
});
it('should get followers page', function (done) {
request(nconf.get('url') + '/api/user/foo/followers', {json: true}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.users[0].username, 'follower');
done();
});
});
it('should get following page', function (done) {
request(nconf.get('url') + '/api/user/follower/following', {json: true}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.users[0].username, 'foo');
done();
});
});
it('should return empty after unfollow', function (done ) {
socketUser.unfollow({uid: uid}, {uid: fooUid}, function (err) {
assert.ifError(err);
request(nconf.get('url') + '/api/user/foo/followers', {json: true}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.users.length, 0);
done();
});
});
});
}); });
after(function (done) { after(function (done) {

@ -610,7 +610,55 @@ describe('User', function () {
}); });
}); });
}); });
});
describe('socket methods', function () {
var socketUser = require('../src/socket.io/user');
it('should fail with invalid data', function (done) {
socketUser.exists({uid: testUid}, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should return true if user/group exists', function (done) {
socketUser.exists({uid: testUid}, {username: 'registered-users'}, function (err, exists) {
assert.ifError(err);
assert(exists);
done();
});
});
it('should return true if user/group exists', function (done) {
socketUser.exists({uid: testUid}, {username: 'John Smith'}, function (err, exists) {
assert.ifError(err);
assert(exists);
done();
});
});
it('should return false if user/group does not exists', function (done) {
socketUser.exists({uid: testUid}, {username: 'doesnot exist'}, function (err, exists) {
assert.ifError(err);
assert(!exists);
done();
});
});
it('should delete user', function (done) {
User.create({username: 'tobedeleted'}, function (err, _uid) {
assert.ifError(err);
socketUser.deleteAccount({uid: _uid}, {}, function (err) {
assert.ifError(err);
socketUser.exists({uid: testUid}, {username: 'doesnot exist'}, function (err, exists) {
assert.ifError(err);
assert(!exists);
done();
});
});
});
});
}); });

Loading…
Cancel
Save