From 517dd03c9d88c146359344daef5f4d6e2ae7bb3f Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Fri, 8 May 2026 15:40:46 -0400 Subject: [PATCH] Add CI workflow and apply ruff formatting --- .github/workflows/ci.yaml | 10 +++++ src/processor/app.py | 78 +++++++++++++++++++++++++-------------- src/receiver/app.py | 4 +- 3 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..3c66f09 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,10 @@ +name: CI +on: + pull_request: + branches: [main] + +jobs: + ci: + uses: Sea-Haven-Industries/.github/.github/workflows/ci-python-sam.yaml@main + with: + source-dirs: "src" diff --git a/src/processor/app.py b/src/processor/app.py index 6591f5a..63ccc13 100644 --- a/src/processor/app.py +++ b/src/processor/app.py @@ -40,24 +40,36 @@ def handler(event, context): is_origin = from_channel == SUBMITTED_CHANNEL token = get_bot_token() - history = slack_get("conversations.history", token, { - "channel": from_channel, - "latest": message_ts, - "limit": 1, - "inclusive": "true", - }) + history = slack_get( + "conversations.history", + token, + { + "channel": from_channel, + "latest": message_ts, + "limit": 1, + "inclusive": "true", + }, + ) original_text = history["messages"][0]["text"] - permalink_resp = slack_get("chat.getPermalink", token, { - "channel": from_channel, - "message_ts": message_ts, - }) + permalink_resp = slack_get( + "chat.getPermalink", + token, + { + "channel": from_channel, + "message_ts": message_ts, + }, + ) permalink = permalink_resp["permalink"] text = REACT_HINT_RE.sub("", original_text).strip() next_stage = STAGES.get(to_channel) next_label = next_stage["label"] if next_stage else None - react_line = f"\n\n_React_ :white_check_mark: _to advance to {next_label}_" if next_label else "" + react_line = ( + f"\n\n_React_ :white_check_mark: _to advance to {next_label}_" + if next_label + else "" + ) permalink_line = ( f"\n\n📎 *Original Submission:* <{permalink}|View Original Message>" if is_origin @@ -65,26 +77,38 @@ def handler(event, context): ) full_text = f"{text}{permalink_line}{react_line}" - slack_post("chat.postMessage", token, { - "channel": to_channel, - "text": full_text, - "mrkdwn": True, - "unfurl_links": False, - "unfurl_media": False, - }) + slack_post( + "chat.postMessage", + token, + { + "channel": to_channel, + "text": full_text, + "mrkdwn": True, + "unfurl_links": False, + "unfurl_media": False, + }, + ) if is_origin: - slack_post("chat.postMessage", token, { - "channel": from_channel, - "thread_ts": message_ts, - "text": f"➡️ Advanced to {label}", - }) + slack_post( + "chat.postMessage", + token, + { + "channel": from_channel, + "thread_ts": message_ts, + "text": f"➡️ Advanced to {label}", + }, + ) print(f"Advanced user submission to {label} (origin preserved)") else: - slack_post("chat.delete", token, { - "channel": from_channel, - "ts": message_ts, - }) + slack_post( + "chat.delete", + token, + { + "channel": from_channel, + "ts": message_ts, + }, + ) print(f"Advanced to {label} and deleted previous copy") diff --git a/src/receiver/app.py b/src/receiver/app.py index c2f2f8b..e7e7228 100644 --- a/src/receiver/app.py +++ b/src/receiver/app.py @@ -85,7 +85,9 @@ def verify_signature(body: str, timestamp: str, signature: str) -> bool: secret = get_signing_secret() secret_len = len(secret) base = f"v0:{timestamp}:{body}".encode("utf-8") - expected = "v0=" + hmac.new(secret.encode("utf-8"), base, hashlib.sha256).hexdigest() + expected = ( + "v0=" + hmac.new(secret.encode("utf-8"), base, hashlib.sha256).hexdigest() + ) ok = hmac.compare_digest(expected, signature) if not ok: print(