mirror of
https://github.com/acid-info/logos-press-engine.git
synced 2025-02-20 13:18:15 +00:00
fix: build error
This commit is contained in:
parent
aa4f024dea
commit
638a2cd686
2
.env
2
.env
@ -2,5 +2,5 @@ UNBODY_API_KEY=
|
||||
UNBODY_PROJECT_ID=
|
||||
SIMPLECAST_ACCESS_TOKEN=
|
||||
REVALIDATE_WEBHOOK_TOKEN=
|
||||
DISCORD_LOGS_WEBHOOK_URL=
|
||||
DISCORD_WEBHOOK=
|
||||
NEXT_PUBLIC_SITE_URL=https://press.logos.co
|
@ -33,16 +33,12 @@ const isBuildTime = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD
|
||||
const isVercel = process.env.VERCEL === '1'
|
||||
|
||||
const websiteUrl = getWebsiteUrl()
|
||||
const discordWebhookURL = process.env.DISCORD_LOGS_WEBHOOK_URL || ''
|
||||
const discordWebhookURL = process.env.DISCORD_WEBHOOK || ''
|
||||
const sendDiscordNotifications =
|
||||
process.env.NODE_ENV === 'production' &&
|
||||
!!discordWebhookURL &&
|
||||
websiteUrl.includes('dev-') // temporary solution to avoid sending duplicate notification messages
|
||||
|
||||
const discordWebhook = new WebhookClient({
|
||||
url: discordWebhookURL,
|
||||
})
|
||||
|
||||
const articleDocument = unbodyDataTypes.get({
|
||||
objectType: 'GoogleDoc',
|
||||
classes: ['article', 'document'],
|
||||
@ -214,15 +210,23 @@ export class UnbodyService {
|
||||
newData.posts = [...newData.articles, ...newData.episodes]
|
||||
newData.allRecords = [...articles, ...episodes, ...staticPages]
|
||||
|
||||
if (!this.firstLoad && !isBuildTime && !isVercel) {
|
||||
const changes = this.findChanges(this.data, newData)
|
||||
if (sendDiscordNotifications)
|
||||
settle(() => this.sendUpdatesToDiscord(changes))
|
||||
}
|
||||
const oldData = { ...this.data }
|
||||
|
||||
this.data = newData
|
||||
if (this.firstLoad) this.firstLoad = false
|
||||
callback(this.data)
|
||||
|
||||
if (!this.firstLoad && !isBuildTime && !isVercel) {
|
||||
const changes = this.findChanges(oldData, newData)
|
||||
if (sendDiscordNotifications) {
|
||||
const [_res, err] = await settle(() =>
|
||||
this.sendUpdatesToDiscord(changes),
|
||||
)
|
||||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
@ -297,6 +301,10 @@ export class UnbodyService {
|
||||
}
|
||||
|
||||
sendUpdatesToDiscord = async (changes: PageRecordChange[]) => {
|
||||
const discordWebhook = new WebhookClient({
|
||||
url: discordWebhookURL,
|
||||
})
|
||||
|
||||
const logs: string[] = []
|
||||
|
||||
const generateLog = async (
|
||||
|
Loading…
x
Reference in New Issue
Block a user