@ -94,6 +94,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
var userID = apiUser . id ;
var userID = apiUser . id ;
var result = users [ userID ] ;
if ( apiUser . pFlags === undefined ) {
apiUser . pFlags = { } ;
}
if ( apiUser . pFlags . min ) {
if ( result !== undefined ) {
return ;
}
}
if ( apiUser . phone ) {
if ( apiUser . phone ) {
apiUser . rPhone = $filter ( 'phoneNumber' ) ( apiUser . phone ) ;
apiUser . rPhone = $filter ( 'phoneNumber' ) ( apiUser . phone ) ;
@ -114,10 +125,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
usernames [ searchUsername ] = userID ;
usernames [ searchUsername ] = userID ;
}
}
if ( apiUser . pFlags === undefined ) {
apiUser . pFlags = { } ;
}
apiUser . sortName = apiUser . pFlags . deleted ? '' : SearchIndexManager . cleanSearchText ( apiUser . first _name + ' ' + ( apiUser . last _name || '' ) ) ;
apiUser . sortName = apiUser . pFlags . deleted ? '' : SearchIndexManager . cleanSearchText ( apiUser . first _name + ' ' + ( apiUser . last _name || '' ) ) ;
var nameWords = apiUser . sortName . split ( ' ' ) ;
var nameWords = apiUser . sortName . split ( ' ' ) ;
@ -191,8 +198,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return users [ id ] && users [ id ] . pFlags . bot ;
return users [ id ] && users [ id ] . pFlags . bot ;
}
}
function hasUser ( id ) {
function hasUser ( id , allowMin ) {
return angular . isObject ( users [ id ] ) ;
var user = users [ id ] ;
return angular . isObject ( user ) && ( ! allowMin || ! user . pFlags . min ) ;
}
}
function getUserPhoto ( id ) {
function getUserPhoto ( id ) {
@ -592,6 +600,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
apiChat . rTitle = RichTextProcessor . wrapRichText ( apiChat . title , { noLinks : true , noLinebreaks : true } ) || _ ( 'chat_title_deleted' ) ;
apiChat . rTitle = RichTextProcessor . wrapRichText ( apiChat . title , { noLinks : true , noLinebreaks : true } ) || _ ( 'chat_title_deleted' ) ;
var result = chats [ apiChat . id ] ;
var titleWords = SearchIndexManager . cleanSearchText ( apiChat . title || '' ) . split ( ' ' ) ;
var titleWords = SearchIndexManager . cleanSearchText ( apiChat . title || '' ) . split ( ' ' ) ;
var firstWord = titleWords . shift ( ) ;
var firstWord = titleWords . shift ( ) ;
var lastWord = titleWords . pop ( ) ;
var lastWord = titleWords . pop ( ) ;
@ -602,16 +611,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if ( apiChat . pFlags === undefined ) {
if ( apiChat . pFlags === undefined ) {
apiChat . pFlags = { } ;
apiChat . pFlags = { } ;
}
}
if ( apiChat . pFlags . min ) {
if ( result !== undefined ) {
return ;
}
}
if ( apiChat . username ) {
if ( apiChat . username ) {
var searchUsername = SearchIndexManager . cleanUsername ( apiChat . username ) ;
var searchUsername = SearchIndexManager . cleanUsername ( apiChat . username ) ;
usernames [ searchUsername ] = apiChat . id ;
usernames [ searchUsername ] = apiChat . id ;
}
}
if ( chats [ apiChat . id ] === undefined ) {
if ( result === undefined ) {
chats [ apiChat . id ] = apiChat ;
result = chats [ apiChat . id ] = apiChat ;
} else {
} else {
safeReplaceObject ( chats [ apiChat . id ] , apiChat ) ;
safeReplaceObject ( result , apiChat ) ;
$rootScope . $broadcast ( 'chat_update' , apiChat . id ) ;
$rootScope . $broadcast ( 'chat_update' , apiChat . id ) ;
}
}
@ -653,7 +667,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
case 'invite' :
case 'invite' :
if ( chat . _ == 'channel' ) {
if ( chat . _ == 'channel' ) {
if ( chat . pFlags . megagroup ) {
if ( chat . pFlags . megagroup ) {
if ( ! chat . pFlags . editor ) {
if ( ! chat . pFlags . editor &&
! ( action == 'invite' && chat . pFlags . democracy ) ) {
return false ;
return false ;
}
}
} else {
} else {
@ -717,8 +732,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
}
}
function hasChat ( id ) {
function hasChat ( id , allowMin ) {
return angular . isObject ( chats [ id ] ) ;
var chat = chats [ id ] ;
return angular . isObject ( chat ) && ( ! allowMin || ! chat . pFlags . min ) ;
}
}
function getChatPhoto ( id ) {
function getChatPhoto ( id ) {
@ -1778,7 +1794,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
apiDoc . duration = attribute . duration ;
apiDoc . duration = attribute . duration ;
apiDoc . w = attribute . w ;
apiDoc . w = attribute . w ;
apiDoc . h = attribute . h ;
apiDoc . h = attribute . h ;
if ( apiDoc . thumb ) {
apiDoc . type = 'video' ;
apiDoc . type = 'video' ;
}
break ;
break ;
case 'documentAttributeSticker' :
case 'documentAttributeSticker' :
apiDoc . sticker = true ;
apiDoc . sticker = true ;
@ -1794,7 +1812,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
apiDoc . stickerSetInput = attribute . stickerset ;
apiDoc . stickerSetInput = attribute . stickerset ;
}
}
}
}
if ( apiDoc . mime _type == 'image/webp' ) {
if ( apiDoc . thumb && apiDoc . mime _type == 'image/webp' ) {
apiDoc . type = 'sticker' ;
apiDoc . type = 'sticker' ;
}
}
break ;
break ;
@ -1804,8 +1822,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
break ;
break ;
case 'documentAttributeAnimated' :
case 'documentAttributeAnimated' :
if ( ( apiDoc . mime _type == 'image/gif' || apiDoc . mime _type == 'video/mp4' ) &&
if ( ( apiDoc . mime _type == 'image/gif' || apiDoc . mime _type == 'video/mp4' ) &&
apiDoc . thumb &&
apiDoc . thumb ) {
apiDoc . thumb . _ == 'photoSize' ) {
apiDoc . type = 'gif' ;
apiDoc . type = 'gif' ;
}
}
apiDoc . animated = true ;
apiDoc . animated = true ;
@ -1846,7 +1863,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if ( doc . file _name ) {
if ( doc . file _name ) {
return doc . file _name ;
return doc . file _name ;
}
}
var fileExt = '.' + doc . mime _type . split ( '. ' ) [ 1 ] ;
var fileExt = '.' + doc . mime _type . split ( '/ ' ) [ 1 ] ;
if ( fileExt == '.octet-stream' ) {
if ( fileExt == '.octet-stream' ) {
fileExt = '' ;
fileExt = '' ;
}
}
@ -2005,7 +2022,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
function saveDocFile ( docID ) {
function saveDocFile ( docID ) {
var doc = docs [ docID ] ,
var doc = docs [ docID ] ,
historyDoc = docsForHistory [ docID ] || doc || { } ,
historyDoc = docsForHistory [ docID ] || doc || { } ,
mimeType = vi de o. mime _type || 'video/mp4' ,
mimeType = doc . mime _type ,
fileName = getFileName ( doc ) ,
fileName = getFileName ( doc ) ,
ext = ( fileName . split ( '.' , 2 ) || [ ] ) [ 1 ] || '' ;
ext = ( fileName . split ( '.' , 2 ) || [ ] ) [ 1 ] || '' ;
@ -2728,8 +2745,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
to _id : AppPeersManager . getOutputPeer ( toID ) ,
to _id : AppPeersManager . getOutputPeer ( toID ) ,
date : updateMessage . date ,
date : updateMessage . date ,
message : updateMessage . message ,
message : updateMessage . message ,
fwd _from _id : updateMessage . fwd _from _id ,
fwd _from : updateMessage . fwd _from ,
fwd _date : updateMessage . fwd _date ,
reply _to _msg _id : updateMessage . reply _to _msg _id ,
reply _to _msg _id : updateMessage . reply _to _msg _id ,
entities : updateMessage . entities
entities : updateMessage . entities
} ,
} ,
@ -2932,13 +2948,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return false ;
return false ;
}
}
if ( update . _ == 'updateNewMessage' ) {
if ( update . _ == 'updateNewMessage' ||
update . _ == 'updateNewChannelMessage' ) {
var message = update . message ;
var message = update . message ;
var fwdPeerID = message . fwd _from _id ? AppPeersManager . getPeerID ( message . fwd _from _id ) : 0 ;
var toPeerID = AppPeersManager . getPeerID ( message . to _id ) ;
var toPeerID = AppPeersManager . getPeerID ( message . to _id ) ;
if ( message . from _id && ! AppUsersManager . hasUser ( message . from _id ) ||
var fwdHeader = message . fwdHeader || { } ;
fwdPeerID > 0 && ! AppUsersManager . hasUser ( fwdPeerID ) ||
if ( message . from _id && ! AppUsersManager . hasUser ( message . from _id , message . pFlags . post ) ||
fwdPeerID < 0 && ! AppChatsManager . hasChat ( - fwdPeerID ) ||
fwdHeader . from _id && ! AppUsersManager . hasUser ( fwdHeader . from _id , ! ! fwdHeader . channel _id ) ||
fwdHeader . channel _id && ! AppChatsManager . hasChat ( fwdHeader . channel _id ) ||
toPeerID > 0 && ! AppUsersManager . hasUser ( toPeerID ) ||
toPeerID > 0 && ! AppUsersManager . hasUser ( toPeerID ) ||
toPeerID < 0 && ! AppChatsManager . hasChat ( - toPeerID ) ) {
toPeerID < 0 && ! AppChatsManager . hasChat ( - toPeerID ) ) {
console . warn ( dT ( ) , 'Short update not enough data' , message ) ;
console . warn ( dT ( ) , 'Short update not enough data' , message ) ;