comparison libervia/backend/plugins/plugin_xep_0048.py @ 4264:3fbd1a1285c1

plugin XEP-0048: don't fail if a type is missing in bookmark data.
author Goffi <goffi@goffi.org>
date Wed, 12 Jun 2024 22:36:15 +0200
parents 5f2d496c633f
children 0d7bb4df2343
comparison
equal deleted inserted replaced
4263:2109d864a3e7 4264:3fbd1a1285c1
441 441
442 def fill_bookmarks(__, _storage_location): 442 def fill_bookmarks(__, _storage_location):
443 bookmarks_ori = getattr(client, "bookmarks_" + _storage_location) 443 bookmarks_ori = getattr(client, "bookmarks_" + _storage_location)
444 if bookmarks_ori is None: 444 if bookmarks_ori is None:
445 return ret 445 return ret
446 data = bookmarks_ori[type_] 446 try:
447 data = bookmarks_ori[type_]
448 except KeyError:
449 log.warning(
450 f"{type_!r} missing in {storage_location} storage."
451 )
452 data = bookmarks_ori[type_] = {}
447 for bookmark in data: 453 for bookmark in data:
448 if type_ == XEP_0048.MUC_TYPE: 454 if type_ == XEP_0048.MUC_TYPE:
449 ret[_storage_location][bookmark.full()] = data[bookmark].copy() 455 ret[_storage_location][bookmark.full()] = data[bookmark].copy()
450 else: 456 else:
451 ret[_storage_location][bookmark] = data[bookmark].copy() 457 ret[_storage_location][bookmark] = data[bookmark].copy()