|
|
@@ -39,6 +39,43 @@ module.exports = {
|
|
39
|
39
|
});
|
|
40
|
40
|
},
|
|
41
|
41
|
|
|
|
42
|
+ get_all_public_infos: function (complete) {
|
|
|
43
|
+ var self = this;
|
|
|
44
|
+ var stream = redis.scanStream({
|
|
|
45
|
+ match: "user:*"
|
|
|
46
|
+ });
|
|
|
47
|
+ var usernames = [];
|
|
|
48
|
+ stream.on('data', function (keys) {
|
|
|
49
|
+ keys.map(function (key) {
|
|
|
50
|
+ usernames.push(key.split(":")[1]);
|
|
|
51
|
+ });
|
|
|
52
|
+ });
|
|
|
53
|
+ stream.on('end', function () {
|
|
|
54
|
+ var user_objects = [];
|
|
|
55
|
+ if (usernames.length === 0) {
|
|
|
56
|
+ complete({
|
|
|
57
|
+ "users": []
|
|
|
58
|
+ })
|
|
|
59
|
+ } else {
|
|
|
60
|
+ for (var ii = 0; ii < usernames.length; ii++) {
|
|
|
61
|
+ self.get_public_user_info(usernames[ii], function (response) {
|
|
|
62
|
+ user_objects.push(response.user);
|
|
|
63
|
+ if (user_objects.length === usernames.length) {
|
|
|
64
|
+ user_objects.sort(function(a, b) {
|
|
|
65
|
+ var textA = a.username.toLowerCase();
|
|
|
66
|
+ var textB = b.username.toLowerCase();
|
|
|
67
|
+ return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
|
|
|
68
|
+ });
|
|
|
69
|
+ complete({
|
|
|
70
|
+ "users": user_objects
|
|
|
71
|
+ })
|
|
|
72
|
+ }
|
|
|
73
|
+ });
|
|
|
74
|
+ }
|
|
|
75
|
+ }
|
|
|
76
|
+ });
|
|
|
77
|
+ },
|
|
|
78
|
+
|
|
42
|
79
|
get_user_from_auth: function (auth, complete) {
|
|
43
|
80
|
var auth_key = "auth-key:" + auth;
|
|
44
|
81
|
|