Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Added basic support for Telegram calls
Browse files Browse the repository at this point in the history
Service messages for calls
Alert with download link
Closes #1404
Closes #1376
  • Loading branch information
zhukov committed May 10, 2017
1 parent 092685d commit e6395fa
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 7 deletions.
21 changes: 19 additions & 2 deletions app/js/directives.js
Expand Up @@ -534,9 +534,26 @@ angular.module('myApp.directives', ['myApp.filters'])
}
})

.directive('myServiceMessage', function () {
.directive('myServiceMessage', function (ErrorService, AppMessagesManager) {
return {
templateUrl: templateUrl('message_service')
templateUrl: templateUrl('message_service'),
scope: {
'historyMessage': '=myServiceMessage'
},
link: link
}

function link ($scope, element, attrs) {
$scope.phoneCallClick = function (messageID) {
var message = AppMessagesManager.getMessage(messageID)
var userID = AppMessagesManager.getMessagePeer(message)
ErrorService.show({
error: {
type: 'PHONECALLS_NOT_SUPPORTED',
userID: userID
}
})
}
}
})

Expand Down
7 changes: 7 additions & 0 deletions app/js/locales/en-us.json
Expand Up @@ -359,6 +359,11 @@
"message_service_joined_by_link": "joined group via invite link",
"message_service_joined": "joined the group",
"message_service_pinned_message": "pinned «{message}»",
"message_service_phonecall_incoming": "Incoming Call {duration}",
"message_service_phonecall_outgoing": "Outgoing Call {duration}",
"message_service_phonecall_missed": "Missed Call {duration}",
"message_service_phonecall_canceled": "Canceled Call {duration}",
"message_service_phonecall": "Phone call {duration}",
"message_service_scored_game": "{scored} in {message}",
"message_service_unsupported_action": "unsupported action {action}",
"message_service_bot_intro_header": "What can this bot do?",
Expand Down Expand Up @@ -391,6 +396,7 @@
"error_modal_password_success_title": "Success!",
"error_modal_password_disabled_title": "Password deactivated",
"error_modal_media_not_supported_title": "Unsupported media",
"error_modal_phonecalls_not_supported_title": "Calls are not available",
"error_modal_recovery_na_title": "Sorry",

"error_modal_network_description": "Please check your internet connection.",
Expand All @@ -408,6 +414,7 @@
"error_modal_username_occupied_description": "Sorry, this username is already taken.",
"error_modal_media_not_supported_description": "Your browser cannot play this media file. Try downloading the file and opening it in a standalone player.",
"error_modal_username_not_found_description": "There is no Telegram account with the username you provided.",
"error_modal_phonecalls_not_supported_description_md": "Unfortunately calls are not supported in Web App at the moment.\nYou can call {user} via mobile apps or native desktop applications.\n{download-link: Download »}",

"error_modal_bad_request_description": "One of the params is missing or invalid.",
"error_modal_unauthorized_description": "This action requires authorization access. Please {login-link: log in}.",
Expand Down
4 changes: 4 additions & 0 deletions app/js/messages_manager.js
Expand Up @@ -1353,6 +1353,10 @@ angular.module('myApp.services')
apiMessage.pFlags.out = false
apiMessage.pFlags.unread = false
break

case 'messageActionPhoneCall':
delete apiMessage.fromID
break
}
if (migrateFrom &&
migrateTo &&
Expand Down
7 changes: 7 additions & 0 deletions app/less/app.less
Expand Up @@ -2130,6 +2130,13 @@ img.im_message_document_thumb {
text-overflow: ellipsis;
vertical-align: middle;
}
.im_service_message_phonecall {
color: inherit !important;
font-weight: bold;
}
.im_service_message_phonecall_duration {
font-weight: normal;
}

.im_message_date,
.im_message_fwd_date {
Expand Down
11 changes: 8 additions & 3 deletions app/partials/desktop/error_modal.html
Expand Up @@ -4,6 +4,7 @@

<h4 ng-if="error" class="md_simple_header" ng-switch="error.type">
<span ng-switch-when="MEDIA_TYPE_NOT_SUPPORTED" my-i18n="error_modal_media_not_supported_title"></span>
<span ng-switch-when="PHONECALLS_NOT_SUPPORTED" my-i18n="error_modal_phonecalls_not_supported_title"></span>
<span ng-switch-when="USERNAME_NOT_OCCUPIED" my-i18n="error_modal_not_found_title"></span>
<span ng-switch-when="PASSWORD_RECOVERY_NA" my-i18n="error_modal_recovery_na_title"></span>
<span ng-switch-default ng-switch="error.code">
Expand Down Expand Up @@ -52,6 +53,11 @@ <h4 ng-if="!error" class="md_simple_header" ng-switch="title_html !== undefined
<span ng-switch-when="2FA_CONFIRM_WAIT_TIME" my-i18n="error_modal_2fa_delayed_time_md">
<my-i18n-param name="time"><span ng-bind="error.waitTime | duration"></span></my-i18n-param>
</span>
<span ng-switch-when="PHONECALLS_NOT_SUPPORTED" my-i18n="error_modal_phonecalls_not_supported_description_md">
<my-i18n-param name="user"><strong my-peer-link="error.userID"></strong></my-i18n-param>
<my-i18n-param name="download-link"><a href="https://telegram.org/dl" target="_blank">{0}</a></my-i18n-param>

</span>

<span ng-switch-when="CALLBACK_RESPONSE" ng-bind-html="error.description_html"></span>

Expand All @@ -69,9 +75,8 @@ <h4 ng-if="!error" class="md_simple_header" ng-switch="title_html !== undefined

</div>

<div ng-if="error" class="error_modal_details" ng-switch="error.detailsShown">
<textarea ng-switch-when="true" rows="3" onclick="this.select()">Method: {{error.input || 'N/A'}}
Url: {{error.url || 'N/A'}}
<div ng-if="error && error.input" class="error_modal_details" ng-switch="error.detailsShown">
<textarea ng-switch-when="true" rows="3" onclick="this.select()">Method: {{error.input || 'N/A'}}{{error.url ? "\nUrl: " + error.url : ''}}
Result: {{error.originalError ? error.originalError : (error.stack ? (error.name || '') + ' ' + (error.description || error.message) : error)}}</textarea>
<div ng-switch-default>
<a class="error_modal_details_link" href="" ng-click="error.detailsShown = true" my-i18n="error_modal_tech_details"></a>
Expand Down
2 changes: 1 addition & 1 deletion app/partials/desktop/message.html
Expand Up @@ -9,7 +9,7 @@
</div>
<div ng-switch-default class="im_service_message">
<a class="im_message_author" ng-if="::historyMessage.fromID > 0" my-peer-link="historyMessage.fromID" short="historyMessage.peerID > 0" color="historyMessage.peerID < 0" no-watch="true"></a>
<span class="im_message_service" my-service-message></span>
<span class="im_message_service" my-service-message="historyMessage"></span>
</div>

<a ng-if="::historyMessage.action._ == 'messageActionChatEditPhoto' || historyMessage.action._ == 'messageActionChannelEditPhoto'" class="im_service_message_photo_thumb" href="" ng-click="openPhoto(historyMessage.action.photo.id)">
Expand Down
10 changes: 10 additions & 0 deletions app/partials/desktop/message_service.html
Expand Up @@ -42,6 +42,16 @@
<my-i18n-param name="message"><a class="im_service_message_pinned" my-pinned-message="::historyMessage.reply_to_mid"></a></my-i18n-param>
</span>

<a ng-switch-when="messageActionPhoneCall" class="im_service_message_phonecall" ng-click="phoneCallClick(historyMessage.mid)">
<my-i18n ng-switch="(historyMessage.pFlags.out ? 'out' : 'in') + (historyMessage.action.reason._ == 'phoneCallDiscardReasonMissed' || historyMessage.action.reason._ == 'phoneCallDiscardReasonBusy' ? 'missed' : 'ok')">
<span ng-switch-when="outmissed" my-i18n-format="message_service_phonecall_canceled"></span>
<span ng-switch-when="inmissed" my-i18n-format="message_service_phonecall_missed"></span>
<span ng-switch-when="outok" my-i18n-format="message_service_phonecall_outgoing"></span>
<span ng-switch-when="inok" my-i18n-format="message_service_phonecall_incoming"></span>
<my-i18n-param name="duration"><span ng-if="historyMessage.action.duration > 0" ng-bind="historyMessage.action.duration | duration" class="im_service_message_phonecall_duration"></span></my-i18n-param>
</my-i18n>
</a>


<span ng-switch-default my-i18n="message_service_unsupported_action">
<my-i18n-param name="action"><span ng-bind="historyMessage.action._"></span></my-i18n-param>
Expand Down
2 changes: 1 addition & 1 deletion app/partials/mobile/message.html
Expand Up @@ -10,7 +10,7 @@
</div>
<div ng-switch-default class="im_service_message">
<a class="im_message_author" ng-if="::historyMessage.fromID > 0" my-peer-link="historyMessage.fromID" short="historyMessage.peerID > 0" color="historyMessage.peerID < 0" no-watch="true"></a>
<span class="im_message_service" my-service-message></span>
<span class="im_message_service" my-service-message="historyMessage"></span>
</div>

<a ng-if="::historyMessage.action._ == 'messageActionChatEditPhoto' || historyMessage.action._ == 'messageActionChannelEditPhoto'" class="im_service_message_photo_thumb" href="" ng-click="openPhoto(historyMessage.action.photo.id)">
Expand Down
10 changes: 10 additions & 0 deletions app/partials/mobile/message_service.html
Expand Up @@ -42,6 +42,16 @@
<my-i18n-param name="message"><a my-pinned-message="historyMessage.reply_to_mid"></a></my-i18n-param>
</span>

<a ng-switch-when="messageActionPhoneCall" class="im_service_message_phonecall" ng-click="phoneCallClick(historyMessage.mid)">
<my-i18n ng-switch="(historyMessage.pFlags.out ? 'out' : 'in') + (historyMessage.action.reason._ == 'phoneCallDiscardReasonMissed' || historyMessage.action.reason._ == 'phoneCallDiscardReasonBusy' ? 'missed' : 'ok')">
<span ng-switch-when="outmissed" my-i18n-format="message_service_phonecall_canceled"></span>
<span ng-switch-when="inmissed" my-i18n-format="message_service_phonecall_missed"></span>
<span ng-switch-when="outok" my-i18n-format="message_service_phonecall_outgoing"></span>
<span ng-switch-when="inok" my-i18n-format="message_service_phonecall_incoming"></span>
<my-i18n-param name="duration"><span ng-if="historyMessage.action.duration > 0" ng-bind="historyMessage.action.duration | duration" class="im_service_message_phonecall_duration"></span></my-i18n-param>
</my-i18n>
</a>

<span ng-switch-default my-i18n="message_service_unsupported_action">
<my-i18n-param name="action"><span ng-bind="historyMessage.action._"></span></my-i18n-param>
</span>
Expand Down

3 comments on commit e6395fa

@artofkot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! When will calls in web.telegram happen, approximately?

@stek29
Copy link
Collaborator

@stek29 stek29 commented on e6395fa Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never, approximately, see #1376

@artofkot
Copy link

@artofkot artofkot commented on e6395fa Aug 18, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.