remove avatar files when we publish a vcard without an avatar. see #2718
This commit is contained in:
parent
adff04903c
commit
e9db205110
|
@ -940,15 +940,17 @@ class ConnectionVcard:
|
|||
iq.setID(id)
|
||||
self.connection.send(iq)
|
||||
|
||||
our_jid = gajim.get_jid_from_account(self.name)
|
||||
# Add the sha of the avatar
|
||||
if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \
|
||||
vcard['PHOTO'].has_key('BINVAL'):
|
||||
photo = vcard['PHOTO']['BINVAL']
|
||||
photo_decoded = base64.decodestring(photo)
|
||||
our_jid = gajim.get_jid_from_account(self.name)
|
||||
gajim.interface.save_avatar_files(our_jid, photo_decoded)
|
||||
avatar_sha = sha.sha(photo_decoded).hexdigest()
|
||||
iq2.getTag('PHOTO').setTagData('SHA', avatar_sha)
|
||||
else:
|
||||
gajim.interface.remove_avatar_files(our_jid)
|
||||
|
||||
self.awaiting_answers[id] = (VCARD_PUBLISHED, iq2)
|
||||
|
||||
|
|
10
src/gajim.py
10
src/gajim.py
|
@ -1196,6 +1196,16 @@ class Interface:
|
|||
path_to_bw_file = path_to_file + '_notif_size_bw.png'
|
||||
bwbuf.save(path_to_bw_file, 'png')
|
||||
|
||||
def remove_avatar_files(self, jid):
|
||||
'''remove avatar files of a jid'''
|
||||
puny_jid = helpers.sanitize_filename(jid)
|
||||
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
||||
for ext in ('.jpeg', '.png', '_notif_size_colored.png',
|
||||
'_notif_size_bw.png'):
|
||||
path_to_original_file = path_to_file + ext
|
||||
if os.path.isfile(path_to_original_file):
|
||||
os.remove(path_to_original_file)
|
||||
|
||||
def add_event(self, account, jid, type_, event_args):
|
||||
'''add an event to the gajim.events var'''
|
||||
# We add it to the gajim.events queue
|
||||
|
|
Loading…
Reference in New Issue