Browse Source

BotsManager draft

master
Igor Zhukov 10 years ago
parent
commit
092aaf3395
  1. 12
      app/js/controllers.js
  2. 40
      app/js/services.js

12
app/js/controllers.js

@ -2512,9 +2512,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2512,9 +2512,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.settings = {notifications: true};
MtpApiManager.invokeApi('users.getFullUser', {
id: AppUsersManager.getUserInput($scope.userID)
}).then(function (userFullResult) {
AppUsersManager.getUserFull($scope.userID).then(function (userFullResult) {
if ($scope.override && $scope.override.phone_number) {
userFullResult.user.phone = $scope.override.phone_number;
if ($scope.override.first_name || $scope.override.last_name) {
@ -2522,8 +2520,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2522,8 +2520,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
userFullResult.user.last_name = $scope.override.last_name;
}
AppUsersManager.saveApiUser(userFullResult.user);
} else {
AppUsersManager.saveApiUser(userFullResult.user, true);
}
AppPhotosManager.savePhoto(userFullResult.profile_photo);
$scope.blocked = userFullResult.blocked;
@ -2537,11 +2533,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2537,11 +2533,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return false;
}
NotificationsManager.getPeerSettings($scope.userID).then(function (settings) {
if (newValue) {
settings.mute_until = 0;
} else {
settings.mute_until = 2000000000;
}
settings.mute_until = newValue ? 0 : 2000000000;
NotificationsManager.updatePeerSettings($scope.userID, settings);
});
});

40
app/js/services.js

@ -185,6 +185,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -185,6 +185,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return users[id] || {id: id, deleted: true, num: 1};
}
function getUserFull (id) {
return MtpApiManager.invokeApi('users.getFullUser', {
id: getUserInput(id)
}).then(function (userFullResult) {
saveApiUser(userFullResult.user, true);
return userFullResult;
});
}
function getSelf() {
return getUser(myID);
}
@ -451,6 +460,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -451,6 +460,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
getUserString: getUserString,
getUserSearchText: getUserSearchText,
hasUser: hasUser,
getUserFull: getUserFull,
importContact: importContact,
importContacts: importContacts,
deleteContacts: deleteContacts,
@ -823,6 +833,36 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -823,6 +833,36 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
})
.service('AppBotsManager', function (AppUsersManager, AppChatsManager) {
return {
getPeerBots: function (peerID) {
var peerBots = [];
if (peerID > 0) {
var user = AppUsersManager.getUser(peerID);
if (!user.pFlags.bot) {
return $q.when(peerBots);
}
return AppUsersManager.getUserFull(peerID).then(function (userFull) {
var botInfo = userFull.bot_info;
if (botInfo && botInfo._ != 'botInfoEmpty') {
peerBots.push(botInfo);
}
return peerBots;
});
}
return AppChatsManager.getFullChat(-peerID).then(function (chatFull) {
angular.forEach(chatFull.bot_info, function (botInfo) {
peerBots.push(botInfo);
});
return peerBots;
});
}
};
})
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, PeersSelectService, Storage, FileManager, TelegramMeWebService, ErrorService, StatusManager, _) {
var messagesStorage = {};

Loading…
Cancel
Save