Added hidden url confirm

This commit is contained in:
Igor Zhukov 2015-10-13 22:48:46 +02:00
parent 6561c99e46
commit 4cb11e3476
4 changed files with 21 additions and 2 deletions

View File

@ -1532,7 +1532,10 @@ angular.module('izhukov.utils', [])
url = 'http://' + url;
}
var tgMeMatch;
if ((tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) {
if (entity._ == 'messageEntityTextUrl') {
url = 'tg://unsafe_url?url=' + encodeURIComponent(url);
}
else if ((tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) {
var path = tgMeMatch[1].split('/');
switch (path[0]) {
case 'joinchat':

View File

@ -222,6 +222,7 @@
"confirm_modal_revoke_group_link": "Are you sure you want to revoke this link? Once you do, no one will be able to join the group using it.",
"confirm_modal_revoke_channel_link": "Are you sure you want to revoke this link? Once you do, no one will be able to join the channel using it.",
"confirm_modal_delete_channel_md": "Are you sure you want to delete this channel?\n\nAll members will be removed and all messages will be lost.",
"confirm_modal_jump_ext_url_md": "Open this link?\n\n{url}",
"confirm_modal_are_u_sure": "Are you sure?",

View File

@ -3684,7 +3684,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
})
.service('LocationParamsService', function ($rootScope, $routeParams, AppPeersManager, AppUsersManager, AppMessagesManager, PeersSelectService, AppStickersManager) {
.service('LocationParamsService', function ($rootScope, $routeParams, AppPeersManager, AppUsersManager, AppMessagesManager, PeersSelectService, AppStickersManager, ErrorService) {
var tgAddrRegExp = /^(web\+)?tg:(\/\/)?(.+)/;
@ -3750,6 +3750,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return true;
}
if (inner &&
(matches = url.match(/^unsafe_url\?url=([^&]+)/))) {
var url = decodeURIComponent(matches[1]);
ErrorService.confirm({
type: 'JUMP_EXT_URL',
url: url
}).then(function () {
window.open(url, '_blank');
});
return true;
}
if (inner &&
(matches = url.match(/^bot_command\?command=(.+?)(?:&bot=(.+))?$/))) {

View File

@ -55,6 +55,9 @@
<div ng-switch-when="REVOKE_GROUP_INVITE_LINK" my-i18n="confirm_modal_revoke_group_link"></div>
<div ng-switch-when="REVOKE_CHANNEL_INVITE_LINK" my-i18n="confirm_modal_revoke_channel_link"></div>
<div ng-switch-when="CHANNEL_DELETE" my-i18n="confirm_modal_delete_channel_md"></div>
<div ng-switch-when="JUMP_EXT_URL" my-i18n="confirm_modal_jump_ext_url_md">
<my-i18n-param name="url"><strong ng-bind="url"></strong></my-i18n-param>
</div>
<span ng-switch-default ng-switch="message.length > 0">