05/29 Fixed a shared item isn't auto updated when it's modified by owner

This commit is contained in:
2026-05-29 14:58:11 -04:00
parent 5f8ce4b5de
commit 977805f5e7
3 changed files with 44 additions and 10 deletions
+12 -1
View File
@@ -145,6 +145,7 @@ def update_item(item_id):
# Re-encrypt accepted shared copies if the owner provided updated ciphertext.
# Each entry: { share_id, enc_data, iv, enc_name?, iv_name? }
from app.models.shared_item import SharedItem
updated_share_ids = []
for upd in (data.get('shared_updates') or []):
share = SharedItem.query.filter_by(
id=upd.get('share_id'),
@@ -157,6 +158,7 @@ def update_item(item_id):
if upd.get('enc_name') is not None:
share.enc_name = upd['enc_name']
share.iv_name = upd.get('iv_name')
updated_share_ids.append(share.id)
try:
db.session.flush()
@@ -168,6 +170,15 @@ def update_item(item_id):
detail=f'Updated {item.item_type} item (id={item.id})',
ip_address=client_ip(),
)
if updated_share_ids:
AuditLog.log(
user_id=g.current_user_id,
action='shared_item.update',
resource_type='shared_item',
resource_id=item.id,
detail=f'Re-encrypted {len(updated_share_ids)} shared copy(ies) for vault item (id={item.id}), share_ids={updated_share_ids}',
ip_address=client_ip(),
)
db.session.commit()
except Exception:
db.session.rollback()
@@ -320,4 +331,4 @@ def audit_bulk_export():
ip_address=client_ip(),
)
db.session.commit()
return jsonify({'logged': len(valid_ids)}), 200
return jsonify({'logged': len(valid_ids)}), 200