Fixed forward to readonly channel
This commit is contained in:
parent
e8af7e40ae
commit
02cfbdc6c0
@ -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'])
|
||||
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'])
|
||||
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'])
|
||||
});
|
||||
}
|
||||
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'])
|
||||
}
|
||||
fwdsSend();
|
||||
|
||||
if (forceDraft == $scope.curDialog.peer) {
|
||||
forceDraft = false;
|
||||
}
|
||||
|
||||
resetDraft();
|
||||
$scope.$broadcast('ui_message_send');
|
||||
});
|
||||
@ -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'])
|
||||
};
|
||||
|
||||
$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'])
|
||||
$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'])
|
||||
|
||||
$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'])
|
||||
|
||||
$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'])
|
||||
|
||||
$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'])
|
||||
};
|
||||
|
||||
$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',
|
||||
|
@ -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'])
|
||||
saveApiChat: saveApiChat,
|
||||
getChat: getChat,
|
||||
isChannel: isChannel,
|
||||
hasRights: hasRights,
|
||||
saveChannelAccess: saveChannelAccess,
|
||||
getChatInput: getChatInput,
|
||||
getChannelInput: getChannelInput,
|
||||
|
@ -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>
|
||||
|
@ -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…
Reference in New Issue
Block a user