diff --git a/src/slack_annotations/format.py b/src/slack_annotations/format.py index 6e9b6d4..e10b363 100644 --- a/src/slack_annotations/format.py +++ b/src/slack_annotations/format.py @@ -101,6 +101,13 @@ def _build_annotation_fields(annotation: dict[str, Any]) -> list[dict[str, Any]] }, {"type": "plain_text", "text": quote}, ] + elif annotation.get("references"): + fields = [ + { + "type": "mrkdwn", + "text": f"*Reply* (<{incontext_link}|in-context link>):", + }, + ] else: fields = [ { diff --git a/tests/unit/slack_annotations/format_test.py b/tests/unit/slack_annotations/format_test.py index 125ee43..f6ae938 100644 --- a/tests/unit/slack_annotations/format_test.py +++ b/tests/unit/slack_annotations/format_test.py @@ -119,3 +119,27 @@ def test_page_note(self): {"type": "plain_text", "text": "(None)"}, ], } + + def test_reply(self): + annotation = { + "user": "acct:test_user_1@hypothes.is", + "uri": "https://example.com/", + "links": {"incontext": "https://hyp.is/test_annotation_id_1/example.com/"}, + "user_info": {"display_name": None}, + "references": ["test_annotation_id_2"], + } + + assert _format_annotation(annotation) == { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "`test_user_1` annotated https://example.com/:", + }, + "fields": [ + { + "type": "mrkdwn", + "text": "*Reply* ():", + }, + {"type": "plain_text", "text": "(None)"}, + ], + }