parent
c5be224add
commit
36ef1084db
@ -2264,7 +2264,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
|
|
||||||
if (attachment._ == 'share_url') {
|
if (attachment._ == 'share_url') {
|
||||||
var url = attachment.url;
|
var url = attachment.url;
|
||||||
var text = attachment.text || '';
|
var text = attachment.text || ' ';
|
||||||
forceDraft = $scope.curDialog.peer;
|
forceDraft = $scope.curDialog.peer;
|
||||||
|
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
|
@ -553,7 +553,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
onContentLoaded(function () {
|
onContentLoaded(function () {
|
||||||
scroller.updateHeight();
|
scroller.updateHeight();
|
||||||
scroller.scrollTo(0);
|
scroller.scrollTo(0);
|
||||||
$scope.$emit('ui_panel_update', {blur: data.enabled});
|
$scope.$emit('ui_panel_update', {blur: data && data.enabled});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
onContentLoaded(function () {
|
onContentLoaded(function () {
|
||||||
@ -759,7 +759,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
return cancelEvent(e);
|
return cancelEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchFocused && e.keyCode == 13) { // Enter
|
if (searchFocused && e.keyCode == 13 && !Config.Navigator.mobile) { // Enter
|
||||||
var currentSelected = $(scrollableWrap).find('.im_dialog_selected')[0] || $(scrollableWrap).find('.im_dialog_wrap a')[0];
|
var currentSelected = $(scrollableWrap).find('.im_dialog_selected')[0] || $(scrollableWrap).find('.im_dialog_wrap a')[0];
|
||||||
if (currentSelected) {
|
if (currentSelected) {
|
||||||
$(currentSelected).trigger('mousedown');
|
$(currentSelected).trigger('mousedown');
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
angular.module('myApp.services')
|
angular.module('myApp.services')
|
||||||
|
|
||||||
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppStickersManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, PeersSelectService, Storage, AppProfileManager, TelegramMeWebService, ErrorService, StatusManager, _) {
|
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppStickersManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, Storage, AppProfileManager, TelegramMeWebService, ErrorService, StatusManager, _) {
|
||||||
|
|
||||||
var messagesStorage = {};
|
var messagesStorage = {};
|
||||||
var messagesForHistory = {};
|
var messagesForHistory = {};
|
||||||
@ -1439,6 +1439,8 @@ angular.module('myApp.services')
|
|||||||
apiFileName = 'document.' + file.type.split('/')[1];
|
apiFileName = 'document.' + file.type.split('/')[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(attachType, apiFileName, file.type);
|
||||||
|
|
||||||
if (historyStorage === undefined) {
|
if (historyStorage === undefined) {
|
||||||
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []};
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []};
|
||||||
}
|
}
|
||||||
@ -1786,19 +1788,35 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatID) {
|
if (chatID) {
|
||||||
return MtpApiManager.invokeApi('messages.addChatUser', {
|
if (AppChatsManager.isChannel(chatID)) {
|
||||||
chat_id: AppChatsManager.getChatInput(chatID),
|
return MtpApiManager.invokeApi('channels.inviteToChannel', {
|
||||||
user_id: AppUsersManager.getUserInput(botID)
|
channel: AppChatsManager.getChannelInput(chatID),
|
||||||
}).then(function (updates) {
|
users: [AppUsersManager.getUserInput(botID)]
|
||||||
ApiUpdatesManager.processUpdateMessage(updates);
|
}).then(function (updates) {
|
||||||
sendText(peerID, '/start@' + bot.username);
|
ApiUpdatesManager.processUpdateMessage(updates);
|
||||||
}, function (error) {
|
|
||||||
if (error && error.type == 'USER_ALREADY_PARTICIPANT') {
|
|
||||||
var bot = AppUsersManager.getUser(botID);
|
|
||||||
sendText(peerID, '/start@' + bot.username);
|
sendText(peerID, '/start@' + bot.username);
|
||||||
error.handled = true;
|
}, function (error) {
|
||||||
}
|
if (error && error.type == 'USER_ALREADY_PARTICIPANT') {
|
||||||
});
|
var bot = AppUsersManager.getUser(botID);
|
||||||
|
sendText(peerID, '/start@' + bot.username);
|
||||||
|
error.handled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return MtpApiManager.invokeApi('messages.addChatUser', {
|
||||||
|
chat_id: AppChatsManager.getChatInput(chatID),
|
||||||
|
user_id: AppUsersManager.getUserInput(botID)
|
||||||
|
}).then(function (updates) {
|
||||||
|
ApiUpdatesManager.processUpdateMessage(updates);
|
||||||
|
sendText(peerID, '/start@' + bot.username);
|
||||||
|
}, function (error) {
|
||||||
|
if (error && error.type == 'USER_ALREADY_PARTICIPANT') {
|
||||||
|
var bot = AppUsersManager.getUser(botID);
|
||||||
|
sendText(peerID, '/start@' + bot.username);
|
||||||
|
error.handled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendText(peerID, '/start');
|
return sendText(peerID, '/start');
|
||||||
@ -2474,28 +2492,6 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.navigator.mozSetMessageHandler) {
|
|
||||||
console.warn('set message handler');
|
|
||||||
window.navigator.mozSetMessageHandler('activity', function(activityRequest) {
|
|
||||||
var source = activityRequest.source;
|
|
||||||
console.log(dT(), 'Received activity', source.name, source.data);
|
|
||||||
|
|
||||||
if (source.name === 'share' && source.data.blobs.length > 0) {
|
|
||||||
PeersSelectService.selectPeers({confirm_type: 'EXT_SHARE_PEER'}).then(function (peerStrings) {
|
|
||||||
angular.forEach(peerStrings, function (peerString) {
|
|
||||||
var peerID = AppPeersManager.getPeerID(peerString);
|
|
||||||
angular.forEach(source.data.blobs, function (blob) {
|
|
||||||
sendFile(peerID, blob, {isMedia: true});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
if (peerStrings.length == 1) {
|
|
||||||
$rootScope.$broadcast('history_focus', {peerString: peerStrings[0]});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var newMessagesHandlePromise = false;
|
var newMessagesHandlePromise = false;
|
||||||
var newMessagesToHandle = {};
|
var newMessagesToHandle = {};
|
||||||
var newDialogsHandlePromise = false;
|
var newDialogsHandlePromise = false;
|
||||||
@ -2564,13 +2560,19 @@ angular.module('myApp.services')
|
|||||||
case 'updateNewChannelMessage':
|
case 'updateNewChannelMessage':
|
||||||
var message = update.message,
|
var message = update.message,
|
||||||
peerID = getMessagePeer(message),
|
peerID = getMessagePeer(message),
|
||||||
historyStorage = historiesStorage[peerID];
|
historyStorage = historiesStorage[peerID],
|
||||||
|
messageForMe = true;
|
||||||
|
|
||||||
if (update._ == 'updateNewChannelMessage' &&
|
if (update._ == 'updateNewChannelMessage') {
|
||||||
!AppChatsManager.isMegagroup(-peerID) &&
|
if (!AppChatsManager.isMegagroup(-peerID) &&
|
||||||
!(message.flags & 16 || message.flags & 2 || (message.flags & 256) == 0)) {
|
!(message.flags & 16 || message.flags & 2 || (message.flags & 256) == 0)) {
|
||||||
// we don't support not important messages in channels yet
|
// we don't support not important messages in channels yet
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
var chat = AppChatsManager.getChat(-peerID);
|
||||||
|
if (chat.pFlags && (chat.pFlags.left || chat.pFlags.kicked)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveMessages([message]);
|
saveMessages([message]);
|
||||||
@ -2771,7 +2773,7 @@ angular.module('myApp.services')
|
|||||||
history = historiesUpdated[peerID] || (historiesUpdated[peerID] = {count: 0, unread: 0, msgs: {}});
|
history = historiesUpdated[peerID] || (historiesUpdated[peerID] = {count: 0, unread: 0, msgs: {}});
|
||||||
|
|
||||||
if (!message.pFlags.out && message.pFlags.unread) {
|
if (!message.pFlags.out && message.pFlags.unread) {
|
||||||
history.pFlags.unread++;
|
history.unread++;
|
||||||
NotificationsManager.cancel('msg' + messageID);
|
NotificationsManager.cancel('msg' + messageID);
|
||||||
}
|
}
|
||||||
history.count++;
|
history.count++;
|
||||||
|
@ -3221,7 +3221,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
else if (!data.image) {
|
else if (!data.image) {
|
||||||
data.image = 'img/icons/icon60.png';
|
data.image = 'img/icons/icon60.png';
|
||||||
}
|
}
|
||||||
console.log('notify image', data.image);
|
// console.log('notify image', data.image);
|
||||||
|
|
||||||
notificationsCount++;
|
notificationsCount++;
|
||||||
|
|
||||||
@ -3899,9 +3899,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (matches = url.match(/^msg_url\?url=([^&]+)(?:&text=(.*))?$/)) {
|
if (matches = url.match(/^msg_url\?url=([^&]+)(?:&text=(.*))?$/)) {
|
||||||
PeersSelectService.selectPeer({
|
PeersSelectService.selectPeer().then(function (toPeerString) {
|
||||||
confirm_type: 'SHARE_URL'
|
|
||||||
}).then(function (toPeerString) {
|
|
||||||
var url = decodeURIComponent(matches[1]);
|
var url = decodeURIComponent(matches[1]);
|
||||||
var text = matches[2] ? decodeURIComponent(matches[2]) : '';
|
var text = matches[2] ? decodeURIComponent(matches[2]) : '';
|
||||||
$rootScope.$broadcast('history_focus', {
|
$rootScope.$broadcast('history_focus', {
|
||||||
@ -3963,6 +3961,62 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window.navigator.mozSetMessageHandler) {
|
||||||
|
console.log(dT(), 'Set activity message handler');
|
||||||
|
window.navigator.mozSetMessageHandler('activity', function(activityRequest) {
|
||||||
|
var source = activityRequest.source;
|
||||||
|
console.log(dT(), 'Received activity', source.name, source.data);
|
||||||
|
|
||||||
|
if (source.name == 'share' && source.data.url) {
|
||||||
|
var tgUrl = 'msg_url?url=' + encodeURIComponent(source.data.url);
|
||||||
|
handleTgProtoAddr(tgUrl);
|
||||||
|
}
|
||||||
|
else if (source.name == 'view' && source.data.url) {
|
||||||
|
var matches = source.data.url.match(tgAddrRegExp);
|
||||||
|
if (matches) {
|
||||||
|
handleTgProtoAddr(matches[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (source.name == 'webrtc-call' && source.data.contact) {
|
||||||
|
var contact = source.data.contact;
|
||||||
|
var phones = [];
|
||||||
|
if (contact.tel != undefined) {
|
||||||
|
for (var i = 0; i < contact.tel.length; i++) {
|
||||||
|
phones.push(contact.tel[i].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var firstName = (contact.givenName || []).join(' ');
|
||||||
|
var lastName = (contact.familyName || []).join(' ');
|
||||||
|
|
||||||
|
if (phones.length) {
|
||||||
|
AppUsersManager.importContact(phones[0], firstName, lastName).then(function (foundUserID) {
|
||||||
|
if (foundUserID) {
|
||||||
|
var peerString = AppPeersManager.getPeerString(foundUserID);
|
||||||
|
$rootScope.$broadcast('history_focus', {peerString: peerString});
|
||||||
|
} else {
|
||||||
|
ErrorService.show({
|
||||||
|
error: {code: 404, type: 'USER_NOT_USING_TELEGRAM'}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (source.name === 'share' && source.data.blobs && source.data.blobs.length > 0) {
|
||||||
|
PeersSelectService.selectPeers({confirm_type: 'EXT_SHARE_PEER'}).then(function (peerStrings) {
|
||||||
|
angular.forEach(peerStrings, function (peerString) {
|
||||||
|
var peerID = AppPeersManager.getPeerID(peerString);
|
||||||
|
angular.forEach(source.data.blobs, function (blob) {
|
||||||
|
AppMessagesManager.sendFile(peerID, blob, {isMedia: true});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
if (peerStrings.length == 1) {
|
||||||
|
$rootScope.$broadcast('history_focus', {peerString: peerStrings[0]});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(document).on('click', function (event) {
|
$(document).on('click', function (event) {
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
if (target &&
|
if (target &&
|
||||||
|
@ -49,23 +49,35 @@
|
|||||||
"activities": {
|
"activities": {
|
||||||
"share": {
|
"share": {
|
||||||
"href": "/index.html",
|
"href": "/index.html",
|
||||||
|
"disposition": "window",
|
||||||
"filters": {
|
"filters": {
|
||||||
"type": ["image/*","audio/*","video/*", "url"],
|
"type": ["image/*","audio/*","video/*", "url"],
|
||||||
"url": {
|
"url": {
|
||||||
"required": true,
|
"pattern": "https?:.{1,16384}",
|
||||||
"regexp": "/^https?:/"
|
"regexp": "^https?:"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"returnValue": false
|
||||||
},
|
},
|
||||||
"view": {
|
"view": {
|
||||||
"href": "/index.html",
|
"href": "/index.html",
|
||||||
|
"disposition": "window",
|
||||||
"filters": {
|
"filters": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": {
|
"url": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"regexp": "/^tg:/"
|
"pattern": "tg:.{1,16384}",
|
||||||
|
"regexp": "^tg:"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"returnValue": false
|
||||||
|
},
|
||||||
|
"webrtc-call": {
|
||||||
|
"href": "index.html",
|
||||||
|
"filters": {
|
||||||
|
"type": "webcontacts/contact"
|
||||||
|
},
|
||||||
|
"disposition": "window"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orientation": "portrait-primary",
|
"orientation": "portrait-primary",
|
||||||
|
Loading…
Reference in New Issue
Block a user