Delete intermediate copies after advancing

This commit is contained in:
Adam Moussa 2026-04-20 19:02:56 -04:00
parent 1ceb113c10
commit 840d36e8c8

View file

@ -11,8 +11,10 @@ _cached_token: str | None = None
SLACK_BOT_TOKEN_SECRET_ARN = os.environ["SLACK_BOT_TOKEN_SECRET_ARN"]
SUBMITTED_CHANNEL = "C0AQ2AWLNEN"
STAGES = {
"C0AQ2AWLNEN": {"next": "C0APLSGABAB", "label": "Processed"},
SUBMITTED_CHANNEL: {"next": "C0APLSGABAB", "label": "Processed"},
"C0APLSGABAB": {"next": "C0AQ09CDJH4", "label": "Authorized"},
"C0AQ09CDJH4": {"next": "C0APYUM1JFP", "label": "Matched"},
}
@ -35,6 +37,7 @@ def handler(event, context):
to_channel = route["next"]
label = route["label"]
is_origin = from_channel == SUBMITTED_CHANNEL
token = get_bot_token()
history = slack_get("conversations.history", token, {
@ -57,7 +60,7 @@ def handler(event, context):
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 to_channel == "C0APLSGABAB"
if is_origin
else ""
)
full_text = f"{text}{permalink_line}{react_line}"
@ -70,11 +73,19 @@ def handler(event, context):
"unfurl_media": False,
})
slack_post("chat.postMessage", token, {
"channel": from_channel,
"thread_ts": message_ts,
"text": f"➡️ Advanced to {label}",
})
if is_origin:
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,
})
print(f"Advanced to {label} and deleted previous copy")
def get_bot_token() -> str: