Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jappix/jappix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValérian Saliou <valerian@valeriansaliou.name>2015-06-11 07:50:40 +0300
committerValérian Saliou <valerian@valeriansaliou.name>2015-06-11 07:50:40 +0300
commited5da558f1f50f56180232f3143315f8d7fe6ede (patch)
tree8bc4d6622441a053ec7563acdb4b47393cffad37
parent4a2730193aa634f876794d2bd959cfdc94a45871 (diff)
parent1ecec5547964316bbaa2966e48e902e9c2621285 (diff)
Merge pull request #553 from lainventoria/use_resource_as_anonymous_nickname
Use the resource when receiving a message from an anonymous account
-rw-r--r--app/javascripts/message.js2
-rw-r--r--app/javascripts/name.js58
2 files changed, 39 insertions, 21 deletions
diff --git a/app/javascripts/message.js b/app/javascripts/message.js
index ec979d65..8374ab81 100644
--- a/app/javascripts/message.js
+++ b/app/javascripts/message.js
@@ -591,7 +591,9 @@ var Message = (function () {
// It does not come from a groupchat user, get the full name
if(!is_groupchat_user) {
+ if (!Name.buddyIsAnonymous(xid)) {
fromName = Name.getBuddy(xid);
+ }
} else {
chatType = 'private';
}
diff --git a/app/javascripts/name.js b/app/javascripts/name.js
index 0feacfe1..1328fe9c 100644
--- a/app/javascripts/name.js
+++ b/app/javascripts/name.js
@@ -131,26 +131,33 @@ var Name = (function () {
// Initialize
var cname, bname;
- // Cut the XID resource
- xid = Common.bareXID(xid);
-
- // This is me?
- if(Utils.isAnonymous() && !xid) {
- bname = Common._e("You");
- } else if(xid == Common.getXID()) {
- bname = self.get();
- }
-
- // Not me!
- else {
- cname = $('#roster .buddy[data-xid="' + escape(xid) + '"]:first .buddy-name').html();
-
- // Complete name exists?
- if(cname) {
- bname = cname.revertHtmlEnc();
- } else {
- bname = Common.getXIDNick(xid);
- }
+ // If the buddy is an anonymous account we use the resource
+ // if not empty
+ if (self.buddyIsAnonymous(xid) && Common.thisResource(xid)) {
+ bname = Common.thisResource(xid);
+ } else {
+
+ // Cut the XID resource
+ xid = Common.bareXID(xid);
+
+ // This is me?
+ if(Utils.isAnonymous() && !xid) {
+ bname = Common._e("You");
+ } else if(xid == Common.getXID()) {
+ bname = self.get();
+ }
+
+ // Not me!
+ else {
+ cname = $('#roster .buddy[data-xid="' + escape(xid) + '"]:first .buddy-name').html();
+
+ // Complete name exists?
+ if(cname) {
+ bname = cname.revertHtmlEnc();
+ } else {
+ bname = Common.getXIDNick(xid);
+ }
+ }
}
return bname;
@@ -225,10 +232,19 @@ var Name = (function () {
};
+ /*
+ * Checks if the XID is from an anonymous account
+ * @public
+ * @param {string} xid
+ */
+ self.buddyIsAnonymous = function(xid) {
+ return /^([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)@/ig.test(xid)
+ }
+
/**
* Return class scope
*/
return self;
-})(); \ No newline at end of file
+})();