-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement embeds by issueId #329
base: main
Are you sure you want to change the base?
Conversation
### Notes This implements a new feature to embed linear links based off of the `issueId` if it's placed in a message, such as `THESIS-123`. Additionally this adds a function to delete the embed if the original message link is deleted / changed. Still need to implement editing the original embed if it changes.
This will now pull in the issue tags dynamically from the Linear API rather than having to define it in `ISSUE_PREFIXES`
Let's switch the `robot.logger.info` into `robot.logger.debug`
This adds support for editing the embeds if the original message is updated with changed issues. Ready to roll out for testing. Adds support to `issueTagRegex` for different cased issues like `iSsUe-111` or `ISSUE-111`
Calling this one ready for review/merge. There is likely some edge cases to resolve but I suppose we can iterate further! I've implemented editing embeds and also grabbing issue |
// let us also track sent embeds to delete them if the original message is deleted or edited WIP | ||
const sentEmbeds = new Map<string, Message>() | ||
|
||
let issueTagRegex: RegExp | null = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If createLinearEmbed
already handles the possibility where the issue URL couldn't be resolved, I wonder if we just make this, generically, \b[A-Z]{3,}-\d+\b
, rather than trying to resolve issue prefixes? The advantage here is that resolving issue prefixes implies we need to periodically refresh them.
|
||
async function initializeIssueTagRegex(linearClient: LinearClient) { | ||
const prefixes = await fetchIssuePrefixes(linearClient) | ||
updateIssueTagRegex(prefixes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really no reason for this to be a separate function tbh.
const embedPromises = matches.map(async (match) => { | ||
const uniqueMatches = new Set<string>() | ||
|
||
urlMatches.forEach((match) => { | ||
const teamName = match[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for all of these you can use named capturing groups.
processedIssues.add(uniqueKey) | ||
uniqueMatches.add(JSON.stringify({ issueId, commentId, teamName })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than do this, make processedIssues
a Map<string, { issueId: string; commentId: string; teamName: string }>
, then .set(uniqueKey, { issueId, commentId, teamName })
. This collapses the processed issues and unique matches array, and then instead of Array.from(uniqueMatches)
you can do Array.from(processedIssues.values())
and skip all the JSON back and forth.
Array.from(uniqueMatches).some( | ||
(uniqueMatch) => JSON.parse(uniqueMatch).issueId === issueId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just uniqueMatches.has("${issueId}-")
?
Notes
This implements a new feature to embed linear links based off of the
issueId
if it's placed in a message, such asTHESIS-123
.Additionally this adds a function to delete the embed if the original message link is deleted / changed.
Still need to implement editing the original embed if it changes.