Skip to content

Commit

Permalink
Support annotation metadata in annotation PATCH-ing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Sep 29, 2023
1 parent 4e01565 commit 72dc3ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions h/schemas/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def validate(self, data):
new_appstruct.get("target_uri", self.existing_target_uri),
)

new_appstruct["metadata_jwe"] = appstruct.pop("metadata_jwe", None)

new_appstruct["extra"] = appstruct

return new_appstruct
Expand Down
7 changes: 6 additions & 1 deletion h/services/annotation_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def update_annotation(
"""
initial_target_uri = annotation.target_uri

annotation_metadata_jwe = data.pop("metadata_jwe", None)
self._update_annotation_values(annotation, data)
if update_timestamp:
annotation.updated = datetime.utcnow()
Expand All @@ -134,9 +135,13 @@ def update_annotation(
document.get("document_uri_dicts", {}),
updated=annotation.updated,
)

self.upsert_annotation_slim(annotation)

if annotation_metadata_jwe:
self._annotation_metadata_service.set_annotation_metadata_from_jwe(
annotation, annotation_metadata_jwe
)

# The search index service by default does not reindex if the existing ES
# entry's timestamp matches the DB timestamp. If we're not changing this
# timestamp, we need to force reindexing.
Expand Down

0 comments on commit 72dc3ae

Please sign in to comment.