fix set avatar
This commit is contained in:
		
							parent
							
								
									d6f807bc0b
								
							
						
					
					
						commit
						3911c72ba9
					
				
					 2 changed files with 3 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -431,8 +431,7 @@ class ConnectionVcard:
 | 
			
		|||
        if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \
 | 
			
		||||
        'BINVAL' in vcard['PHOTO']:
 | 
			
		||||
            photo = vcard['PHOTO']['BINVAL']
 | 
			
		||||
            photo_decoded = base64.b64decode(photo.encode('utf-8')).decode(
 | 
			
		||||
                'utf-8')
 | 
			
		||||
            photo_decoded = base64.b64decode(photo.encode('utf-8'))
 | 
			
		||||
            gajim.interface.save_avatar_files(our_jid, photo_decoded)
 | 
			
		||||
            avatar_sha = hashlib.sha1(photo_decoded).hexdigest()
 | 
			
		||||
            iq2.getTag('PHOTO').setTagData('SHA', avatar_sha)
 | 
			
		||||
| 
						 | 
				
			
			@ -685,7 +684,7 @@ class ConnectionVcard:
 | 
			
		|||
        'BINVAL' in vcard['PHOTO']:
 | 
			
		||||
            photo = vcard['PHOTO']['BINVAL']
 | 
			
		||||
            try:
 | 
			
		||||
                photo_decoded = base64.b64decode(photo.encode('utf-8')).decode('utf-8')
 | 
			
		||||
                photo_decoded = base64.b64decode(photo.encode('utf-8'))
 | 
			
		||||
                avatar_sha = hashlib.sha1(photo_decoded).hexdigest()
 | 
			
		||||
            except Exception:
 | 
			
		||||
                avatar_sha = ''
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -171,8 +171,7 @@ class ProfileWindow:
 | 
			
		|||
            button.show()
 | 
			
		||||
            text_button = self.xml.get_object('NOPHOTO_button')
 | 
			
		||||
            text_button.hide()
 | 
			
		||||
            self.avatar_encoded = base64.b64encode(data.encode('utf-8')).decode(
 | 
			
		||||
                'utf-8')
 | 
			
		||||
            self.avatar_encoded = base64.b64encode(data).decode('utf-8')
 | 
			
		||||
            # returns None if unknown type
 | 
			
		||||
            self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
 | 
			
		||||
            if must_delete:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue