Browse Source

Fixed forward to readonly channel

master
Igor Zhukov 9 years ago
parent
commit
02cfbdc6c0
  1. 35
      app/js/controllers.js
  2. 20
      app/js/services.js
  3. 19
      app/partials/desktop/peer_select.html
  4. 18
      app/partials/mobile/peer_select.html

35
app/js/controllers.js

@ -876,6 +876,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -876,6 +876,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (dialogsResult.dialogs.length) {
angular.forEach(dialogsResult.dialogs, function (dialog) {
if ($scope.canSend &&
AppPeersManager.isChannel(dialog.peerID) &&
!AppChatsManager.hasRights(-dialog.peerID, 'send')) {
return;
}
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog);
if (!searchMessages) {
peersInDialogs[dialog.peerID] = true;
@ -927,6 +932,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -927,6 +932,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var dialogsList = searchMessages ? $scope.foundMessages : $scope.dialogs;
angular.forEach(dialogsResult.dialogs, function (dialog) {
if ($scope.canSend &&
AppPeersManager.isChannel(dialog.peerID) &&
!AppChatsManager.hasRights(-dialog.peerID, 'send')) {
return;
}
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog);
if (!searchMessages) {
peersInDialogs[dialog.peerID] = true;
@ -986,6 +996,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -986,6 +996,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
angular.forEach(result.results, function(contactFound) {
var peerID = AppPeersManager.getPeerID(contactFound);
if (peersInDialogs[peerID] === undefined) {
if ($scope.canSend &&
AppPeersManager.isChannel(peerID) &&
!AppChatsManager.hasRights(-peerID, 'send')) {
return;
}
$scope.foundPeers.push({
id: peerID,
username: AppPeersManager.getPeer(peerID).username,
@ -1681,7 +1696,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1681,7 +1696,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
});
}
if (selectedMessageIDs.length) {
PeersSelectService.selectPeer().then(function (peerString) {
PeersSelectService.selectPeer({canSend: true}).then(function (peerString) {
selectedCancel();
$rootScope.$broadcast('history_focus', {
peerString: peerString,
@ -2106,6 +2121,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2106,6 +2121,10 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
fwdsSend();
if (forceDraft == $scope.curDialog.peer) {
forceDraft = false;
}
resetDraft();
$scope.$broadcast('ui_message_send');
});
@ -2476,7 +2495,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2476,7 +2495,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.forward = function () {
var messageID = $scope.messageID;
PeersSelectService.selectPeer().then(function (peerString) {
PeersSelectService.selectPeer({canSend: true}).then(function (peerString) {
$rootScope.$broadcast('history_focus', {
peerString: peerString,
attachment: {
@ -2800,7 +2819,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2800,7 +2819,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
};
$scope.forward = function () {
PeersSelectService.selectPeer({confirm_type: 'FORWARD_PEER'}).then(function (peerString) {
PeersSelectService.selectPeer({confirm_type: 'FORWARD_PEER', canSend: true}).then(function (peerString) {
var peerID = AppPeersManager.getPeerID(peerString);
AppMessagesManager.sendOther(peerID, {
_: 'inputMediaPhoto',
@ -2871,7 +2890,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2871,7 +2890,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.canDelete = isChannel ? chat.pFlags.creator : true;
$scope.forward = function () {
PeersSelectService.selectPeer({confirm_type: 'FORWARD_PEER'}).then(function (peerString) {
PeersSelectService.selectPeer({confirm_type: 'FORWARD_PEER', canSend: true}).then(function (peerString) {
var peerID = AppPeersManager.getPeerID(peerString);
AppMessagesManager.sendOther(peerID, {
_: 'inputMediaPhoto',
@ -2926,7 +2945,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2926,7 +2945,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.forward = function () {
var messageID = $scope.messageID;
PeersSelectService.selectPeer().then(function (peerString) {
PeersSelectService.selectPeer({canSend: true}).then(function (peerString) {
$rootScope.$broadcast('history_focus', {
peerString: peerString,
attachment: {
@ -2961,7 +2980,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2961,7 +2980,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.forward = function () {
var messageID = $scope.messageID;
PeersSelectService.selectPeer().then(function (peerString) {
PeersSelectService.selectPeer({canSend: true}).then(function (peerString) {
$rootScope.$broadcast('history_focus', {
peerString: peerString,
attachment: {
@ -2998,7 +3017,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2998,7 +3017,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.forward = function () {
var messageID = $scope.messageID;
PeersSelectService.selectPeer().then(function (peerString) {
PeersSelectService.selectPeer({canSend: true}).then(function (peerString) {
$rootScope.$broadcast('history_focus', {
peerString: peerString,
attachment: {
@ -3114,7 +3133,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -3114,7 +3133,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
};
$scope.shareContact = function () {
PeersSelectService.selectPeer({confirm_type: 'SHARE_CONTACT_PEER'}).then(function (peerString) {
PeersSelectService.selectPeer({confirm_type: 'SHARE_CONTACT_PEER', canSend: true}).then(function (peerString) {
var peerID = AppPeersManager.getPeerID(peerString);
AppMessagesManager.sendOther(peerID, {
_: 'inputMediaContact',

20
app/js/services.js

@ -614,6 +614,25 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -614,6 +614,25 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return chats[id] || {id: id, deleted: true};
}
function hasRights (id, action) {
if (chats[id] === undefined) {
return false;
}
var chat = getChat(id);
if (chat._ == 'chatForbidden' ||
chat._ == 'channelForbidden' ||
chat.pFlags.kicked ||
chat.pFlags.left) {
return false;
}
if (isChannel(id) && action == 'send') {
if (!chat.pFlags.creator && !chat.pFlags.editor) {
return false;
}
}
return true;
}
function resolveUsername (username) {
return usernames[username] || 0;
}
@ -744,6 +763,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -744,6 +763,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
saveApiChat: saveApiChat,
getChat: getChat,
isChannel: isChannel,
hasRights: hasRights,
saveChannelAccess: saveChannelAccess,
getChatInput: getChatInput,
getChannelInput: getChannelInput,

19
app/partials/desktop/peer_select.html

@ -44,6 +44,25 @@ @@ -44,6 +44,25 @@
</li>
</ul>
</div>
<div class="im_dialogs_contacts_wrap" ng-show="foundPeers.length > 0">
<h5 my-i18n="im_found_title"></h5>
<ul class="nav nav-pills nav-stacked">
<li class="im_dialog_wrap" ng-repeat="foundPeer in foundPeers track by foundPeer.id" ng-class="{active: selectedPeers[foundPeer.id] !== undefined}">
<a class="im_dialog" ng-click="dialogSelect(foundPeer.peerString)">
<div class="im_dialog_photo pull-left" my-peer-photolink="foundPeer.id" img-class="im_dialog_photo" watch="true"></div>
<div class="im_dialog_message_wrap">
<div class="im_dialog_peer">
<span class="im_dialog_user" my-peer-link="foundPeer.id"></span>
</div>
<div class="im_dialog_message">
<span class="im_dialog_message_text" ng-bind="::'@' + foundPeer.username"></span>
</div>
</div>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>

18
app/partials/mobile/peer_select.html

@ -60,6 +60,24 @@ @@ -60,6 +60,24 @@
</li>
</ul>
</div>
<div class="im_dialogs_contacts_wrap" ng-show="foundPeers.length > 0">
<h5 my-i18n="im_found_title"></h5>
<ul class="nav nav-pills nav-stacked">
<li class="im_dialog_wrap" ng-repeat="foundPeer in foundPeers track by foundPeer.id" ng-class="{active: selectedPeers[foundPeer.id] !== undefined}">
<a class="im_dialog" ng-click="dialogSelect(foundPeer.peerString)">
<div class="im_dialog_photo pull-left" my-peer-photolink="foundPeer.id" img-class="im_dialog_photo" watch="true"></div>
<div class="im_dialog_message_wrap">
<div class="im_dialog_peer">
<span class="im_dialog_user" my-peer-link="foundPeer.id"></span>
</div>
<div class="im_dialog_message">
<span class="im_dialog_message_text" ng-bind="::'@' + foundPeer.username"></span>
</div>
</div>
</a>
</li>
</ul>
</div>
</div>
</div>

Loading…
Cancel
Save