-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect to linen if the thread exists
- Loading branch information
Showing
8 changed files
with
127 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next/types'; | ||
import { prisma } from '@linen/database'; | ||
|
||
export async function create({ url }: { url: string }) { | ||
if (isArchiveUrl(url)) { | ||
const parts = url.split('/'); | ||
const last = parts[parts.length - 1]; | ||
if (last.startsWith('p')) { | ||
const { length } = last; | ||
const id = | ||
last.slice(1, length - 6) + '.' + last.slice(length - 6, length); | ||
const thread = await prisma.threads.findFirst({ | ||
where: { | ||
externalThreadId: id, | ||
}, | ||
}); | ||
if (thread) { | ||
return { | ||
status: 200, | ||
data: { | ||
incrementId: thread.incrementId, | ||
}, | ||
}; | ||
} else { | ||
return { | ||
status: 404, | ||
}; | ||
} | ||
} | ||
} | ||
return { | ||
status: 400, | ||
}; | ||
} | ||
|
||
function isArchiveUrl(input: string): boolean { | ||
const url = new URL(input); | ||
if ( | ||
url.hostname.endsWith('.slack.com') && | ||
url.pathname.startsWith('/archives/') | ||
) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export default async function handler( | ||
request: NextApiRequest, | ||
response: NextApiResponse | ||
) { | ||
const { status, data } = await create(request.body); | ||
return response.status(status).json(data || {}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,4 +559,4 @@ | |
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bf32a40
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.
Successfully deployed to the following URLs:
linen-dev – ./
*.linen.dev
chat.delta.io
www.linen.dev
archive.ory.sh
linen.delta.io
chat.osquery.io
forum.lakefs.io
linen.community
linen.nixtla.io
discuss.flyte.io
linen.prefect.io
community.seam.co
discuss.flyte.org
linen.authzed.com
archive.pulumi.com
discuss.dagster.io
linen.papercups.io
archive.rancher.com
chat.pantsbuild.org
community.garden.io
linen.growthbook.io
linen.linentest.com
osquery.fleetdm.com
community.cerbos.dev
community.nintee.com
discord.supabase.com
linen-dev.vercel.app
threads.netmaker.org
www.thegrowthpros.io
community.screena.com
community.wiremock.io
papercups-io.linen.dev
linen-discord.kedro.org
community-chat.relate.kr
community-chat.signoz.io
linen.futureofcoding.org
community-chat.orchest.io
community-chat.questdb.io
community.getofficely.com
community.supertokens.com
slack-archive.rancher.com
linen-dev-linen.vercel.app
slack-chats.kotlinlang.org
community-chat.infracost.io
web.open-source-silicon.dev
community-chat.nebula-graph.io
archive.netsuiteprofessionals.com
community.platformengineering.org
linen-dev-git-main-linen.vercel.app
linen.dev
thegrowthpros.io
orchest.linen.dev
osquery.linen.dev
questdb.linen.dev
flyte-org.linen.dev
open-pdks.efabless.io
opensilicon.efabless.io
pulumi-community.linen.dev
signoz-community.linen.dev
infracost-community.linen.dev
netsuiteprofessionals.linen.dev