Skip to content

Commit d2f3c5b

Browse files
committed
[push] Variables for API messages
1 parent e1d6b27 commit d2f3c5b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

plugins/push/api/send/audience.js

+3
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ class Pusher extends PusherPopper {
678678
if (!note) {
679679
continue;
680680
}
681+
for (let k in (this.variables || {})) {
682+
note.pr[k] = this.variables[k];
683+
}
681684

682685
let p = pf[0],
683686
d = note._id.getTimestamp().getTime(),

plugins/push/frontend/public/javascripts/countly.models.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,12 @@
816816
return;
817817
}
818818
Object.keys(userPropertiesDto).forEach(function(key) {
819-
userPropertiesDto[key].l = countlyPushNotification.helper.findUserPropertyLabelByValue(userPropertiesDto[key].k, userProperties);
819+
if (userPropertiesDto[key].t === UserPropertyTypeEnum.API) {
820+
userPropertiesDto[key].l = userPropertiesDto[key].k;
821+
}
822+
else {
823+
userPropertiesDto[key].l = countlyPushNotification.helper.findUserPropertyLabelByValue(userPropertiesDto[key].k, userProperties);
824+
}
820825
});
821826
},
822827
getUserPropertyElement: function(index, userProperty) {
@@ -841,6 +846,20 @@
841846
isAdjacentIndex: function(previousIndex, currentIndex) {
842847
return (parseInt(currentIndex) - 1) === parseInt(previousIndex);
843848
},
849+
decodeHtml: function(str) {
850+
var map =
851+
{
852+
'&': '&',
853+
'&lt;': '<',
854+
'&gt;': '>',
855+
'&quot;': '"',
856+
'&#039;': "'",
857+
'&#39;': "'"
858+
};
859+
return str.replace(/&amp;|&lt;|&gt;|&quot;|&#039;|&#39;/g, function(m) {
860+
return map[m];
861+
});
862+
},
844863
buildMessageText: function(message, userPropertiesDto) {
845864
var self = this;
846865
if (!message) {
@@ -849,7 +868,6 @@
849868
if (!userPropertiesDto) {
850869
return message;
851870
}
852-
var messageInHTMLString = message;
853871
// var html = '',
854872
// keys = this.sortUserProperties(userPropertiesDto),
855873
// ranges = [-1]
@@ -878,6 +896,7 @@
878896
// }
879897
// });
880898
// return html;
899+
var messageInHTMLString = this.decodeHtml(message);
881900
var buildMessageLength = 0;
882901
var previousIndex = undefined;
883902
this.sortUserProperties(userPropertiesDto).forEach(function(currentUserPropertyIndex, index) {

0 commit comments

Comments
 (0)