From 8e5d43c566dc7c3a0dc5b82d91b3b9b9954c7bc5 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Mon, 4 Dec 2023 17:03:05 +0000 Subject: [PATCH] Add a 'Write a PREreview' button to the Slack message --- src/Slack.ts | 8 ++++++++ src/index.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Slack.ts b/src/Slack.ts index 4d489c0..cdecce1 100644 --- a/src/Slack.ts +++ b/src/Slack.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@effect/platform' import { Schema } from '@effect/schema' import { Context, Data, Effect } from 'effect' +import * as Url from './Url.js' export interface SlackApiConfig { readonly accessToken: string @@ -20,9 +21,16 @@ const MrkdwnTextObjectSchema = Schema.struct({ const TextObjectSchema = Schema.union(PlainTextObjectSchema, MrkdwnTextObjectSchema) +const ButtonElementSchema = Schema.struct({ + type: Schema.literal('button'), + text: PlainTextObjectSchema, + url: Url.UrlFromStringSchema(Schema.string), +}) + const SectionBlockSchema = Schema.struct({ type: Schema.literal('section'), text: TextObjectSchema, + accessory: Schema.optional(Schema.union(ButtonElementSchema)), }) const BlockSchema = Schema.union(SectionBlockSchema) diff --git a/src/index.ts b/src/index.ts index 0337be6..2a18b0b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,6 +60,19 @@ const serve = HttpServer.router.empty.pipe( Doi.toUrl(reviewAction.object['ietf:cite-as']).href }|${reviewAction.object['ietf:cite-as']}>`, }, + accessory: { + type: 'button', + text: { + type: 'plain_text', + text: 'Write a PREreview', + }, + url: new URL( + `https://prereview.org/preprints/doi-${reviewAction.object['ietf:cite-as'] + .toLowerCase() + .replaceAll('-', '+') + .replaceAll('/', '-')}/write-a-prereview`, + ), + }, }, ], }),