summaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
authorYukai Huang2017-01-15 11:33:22 +0800
committerYukai Huang2017-01-15 11:33:22 +0800
commitc0e8306961a47e7a2ba52d0445c12aaa5fe07949 (patch)
treecec2451fd8afa80210d966d51dcba875bf3a6ffd /lib/models
parent0f833f099f61b93e76a5f32175580fc2c0b9dc1a (diff)
parent3d6b31921651e71ef68fdc88af4ddef50cc9bcb3 (diff)
Merge branch 'frontend-next' into t216-refactor-common
Diffstat (limited to '')
-rw-r--r--lib/models/note.js6
-rw-r--r--lib/models/user.js11
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/models/note.js b/lib/models/note.js
index 132f8b1e..86112973 100644
--- a/lib/models/note.js
+++ b/lib/models/note.js
@@ -23,7 +23,7 @@ var logger = require("../logger.js");
var ot = require("../ot/index.js");
// permission types
-var permissionTypes = ["freely", "editable", "locked", "private"];
+var permissionTypes = ["freely", "editable", "limited", "locked", "protected", "private"];
module.exports = function (sequelize, DataTypes) {
var Note = sequelize.define("Note", {
@@ -333,7 +333,7 @@ module.exports = function (sequelize, DataTypes) {
if (meta.slideOptions && (typeof meta.slideOptions == "object"))
_meta.slideOptions = meta.slideOptions;
}
- return _meta;
+ return _meta;
},
updateAuthorshipByOperation: function (operation, userId, authorships) {
var index = 0;
@@ -532,4 +532,4 @@ module.exports = function (sequelize, DataTypes) {
});
return Note;
-}; \ No newline at end of file
+};
diff --git a/lib/models/user.js b/lib/models/user.js
index aaf344de..7d27242c 100644
--- a/lib/models/user.js
+++ b/lib/models/user.js
@@ -7,6 +7,7 @@ var scrypt = require('scrypt');
// core
var logger = require("../logger.js");
+var letterAvatars = require('../letter-avatars.js');
module.exports = function (sequelize, DataTypes) {
var User = sequelize.define("User", {
@@ -105,6 +106,16 @@ module.exports = function (sequelize, DataTypes) {
case "google":
photo = profile.photos[0].value.replace(/(\?sz=)\d*$/i, '$196');
break;
+ case "ldap":
+ //no image api provided,
+ //use gravatar if email exists,
+ //otherwise generate a letter avatar
+ if (profile.emails[0]) {
+ photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0]) + '?s=96';
+ } else {
+ photo = letterAvatars(profile.username);
+ }
+ break;
}
return photo;
},