Skip to content

Commit

Permalink
Add a 'Write a PREreview' button to the Slack message
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Dec 4, 2023
1 parent 3868c6a commit 8e5d43c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Slack.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
},
},
],
}),
Expand Down

0 comments on commit 8e5d43c

Please sign in to comment.