Skip to content

Commit

Permalink
Render replies differently than annotations (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomilov authored Dec 10, 2024
1 parent 97bc112 commit 149d7ae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/slack_annotations/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/slack_annotations/format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,27 @@ def test_page_note(self):
{"type": "plain_text", "text": "(None)"},
],
}

def test_reply(self):
annotation = {
"user": "acct:[email protected]",
"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* (<https://hyp.is/test_annotation_id_1/example.com/|in-context link>):",
},
{"type": "plain_text", "text": "(None)"},
],
}

0 comments on commit 149d7ae

Please sign in to comment.