Pārlūkot izejas kodu

Fixes setting custom avatar based on the email and reverts the functionality to set custom avatar links to replace the default gravatars.

master
damencho 10 gadus atpakaļ
vecāks
revīzija
01a9d47959
1 mainītis faili ar 18 papildinājumiem un 8 dzēšanām
  1. 18
    8
      modules/UI/avatar/Avatar.js

+ 18
- 8
modules/UI/avatar/Avatar.js Parādīt failu

@@ -1,4 +1,4 @@
1
-/* global Strophe, APP, MD5, config */
1
+/* global Strophe, APP, MD5, config, interfaceConfig */
2 2
 var users = {};
3 3
 
4 4
 var Avatar = {
@@ -46,17 +46,27 @@ var Avatar = {
46 46
             console.error("Get gravatar - id is undefined");
47 47
             return null;
48 48
         }
49
+
50
+        // Default to using gravatar.
51
+        var urlPref = 'https://www.gravatar.com/avatar/';
52
+        var urlSuf = "?d=wavatar&size=" + (size || "30");
53
+
54
+        // If we have a real email we will use it for the gravatar and we'll
55
+        // use the pre-configured URL if any. Otherwise, it's a random avatar.
49 56
         var email = users[id];
50
-        if (!email) {
51
-            console.warn(
52
-                "No avatar stored yet for " + id + " - using user id as ID"
53
-            );
54
-            email = id;
57
+        if (email && email.indexOf('@')) {
58
+            id = email;
59
+
60
+            if (interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
61
+                urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
62
+                urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
63
+            }
55 64
         }
65
+
56 66
         if (!config.disableThirdPartyRequests) {
57
-            return 'https://www.gravatar.com/avatar/' +
67
+            return urlPref +
58 68
                 MD5.hexdigest(id.trim().toLowerCase()) +
59
-                "?d=wavatar&size=" + (size || "30");
69
+                urlSuf;
60 70
         } else {
61 71
             return 'images/avatar2.png';
62 72
         }

Notiek ielāde…
Atcelt
Saglabāt