diff options
Diffstat (limited to 'apps/comments/js/commentmodel.js')
-rw-r--r-- | apps/comments/js/commentmodel.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/apps/comments/js/commentmodel.js b/apps/comments/js/commentmodel.js index 89492707b61..e75c79b3f08 100644 --- a/apps/comments/js/commentmodel.js +++ b/apps/comments/js/commentmodel.js @@ -35,7 +35,8 @@ 'creationDateTime': '{' + NS_OWNCLOUD + '}creationDateTime', 'objectType': '{' + NS_OWNCLOUD + '}objectType', 'objectId': '{' + NS_OWNCLOUD + '}objectId', - 'isUnread': '{' + NS_OWNCLOUD + '}isUnread' + 'isUnread': '{' + NS_OWNCLOUD + '}isUnread', + 'mentions': '{' + NS_OWNCLOUD + '}mentions' }, parse: function(data) { @@ -48,8 +49,30 @@ creationDateTime: data.creationDateTime, objectType: data.objectType, objectId: data.objectId, - isUnread: (data.isUnread === 'true') + isUnread: (data.isUnread === 'true'), + mentions: this._parseMentions(data.mentions) }; + }, + + _parseMentions: function(mentions) { + if(_.isUndefined(mentions)) { + return {}; + } + var result = {}; + for(var i in mentions) { + var mention = mentions[i]; + if(_.isUndefined(mention.localName) || mention.localName !== 'mention') { + continue; + } + result[i] = {}; + for (var child = mention.firstChild; child; child = child.nextSibling) { + if(_.isUndefined(child.localName) || !child.localName.startsWith('mention')) { + continue; + } + result[i][child.localName] = child.textContent; + } + } + return result; } }); |