|
816 | 816 | return;
|
817 | 817 | }
|
818 | 818 | 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 | + } |
820 | 825 | });
|
821 | 826 | },
|
822 | 827 | getUserPropertyElement: function(index, userProperty) {
|
|
841 | 846 | isAdjacentIndex: function(previousIndex, currentIndex) {
|
842 | 847 | return (parseInt(currentIndex) - 1) === parseInt(previousIndex);
|
843 | 848 | },
|
| 849 | + decodeHtml: function(str) { |
| 850 | + var map = |
| 851 | + { |
| 852 | + '&': '&', |
| 853 | + '<': '<', |
| 854 | + '>': '>', |
| 855 | + '"': '"', |
| 856 | + ''': "'", |
| 857 | + ''': "'" |
| 858 | + }; |
| 859 | + return str.replace(/&|<|>|"|'|'/g, function(m) { |
| 860 | + return map[m]; |
| 861 | + }); |
| 862 | + }, |
844 | 863 | buildMessageText: function(message, userPropertiesDto) {
|
845 | 864 | var self = this;
|
846 | 865 | if (!message) {
|
|
849 | 868 | if (!userPropertiesDto) {
|
850 | 869 | return message;
|
851 | 870 | }
|
852 |
| - var messageInHTMLString = message; |
| 871 | + // var html = '', |
| 872 | + // keys = this.sortUserProperties(userPropertiesDto), |
| 873 | + // ranges = [-1] |
| 874 | + // .concat(keys.map(function(k) { |
| 875 | + // return parseInt(k); |
| 876 | + // })) |
| 877 | + // .concat([-1]); |
| 878 | + |
| 879 | + // ranges.forEach(function(start, idx) { |
| 880 | + // if (idx === ranges.length - 1) { |
| 881 | + // return; |
| 882 | + // } |
| 883 | + |
| 884 | + // var end = ranges[idx + 1]; |
| 885 | + // if (end === 0) { // prop at index 0 |
| 886 | + // return; |
| 887 | + // } |
| 888 | + // else if (start === -1) { // first range |
| 889 | + // html += message.substr(0, end) + self.getUserPropertyElement(end, userPropertiesDto[end]); |
| 890 | + // } |
| 891 | + // else if (end === -1) { // last range |
| 892 | + // html += message.substr(start); |
| 893 | + // } |
| 894 | + // else { |
| 895 | + // html += message.substr(start, end - start) + self.getUserPropertyElement(end, userPropertiesDto[end]); |
| 896 | + // } |
| 897 | + // }); |
| 898 | + // return html; |
| 899 | + var messageInHTMLString = this.decodeHtml(message); |
853 | 900 | var buildMessageLength = 0;
|
854 | 901 | var previousIndex = undefined;
|
855 | 902 | this.sortUserProperties(userPropertiesDto).forEach(function(currentUserPropertyIndex, index) {
|
|
0 commit comments