mirror of
https://github.com/wassname/talk.git
synced 2026-06-27 16:47:24 +08:00
Add tenantDomain to StoryCreatedEventPayload (#2899)
* Add tenantID and siteID to StoryCreatedEventPayload * fix: added tenantID to payload * Remove tenantID from StoryCreatedCoralEvent * Add tenantDomain to webhook schema * fix: small comment fixes Co-authored-by: Wyatt Johnson <me@wyattjoh.ca>
This commit is contained in:
+15
@@ -174,6 +174,16 @@ function when comparing signatures.
|
|||||||
* date when this event was created.
|
* date when this event was created.
|
||||||
*/
|
*/
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tenantID is the ID of the Tenant that this event originated at.
|
||||||
|
*/
|
||||||
|
tenantID: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tenantDomain is the domain that is associated with this Tenant that this event originated at.
|
||||||
|
*/
|
||||||
|
tenantDomain: string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -199,6 +209,11 @@ function when comparing signatures.
|
|||||||
* storyURL is the URL of the newly created Story.
|
* storyURL is the URL of the newly created Story.
|
||||||
*/
|
*/
|
||||||
storyURL: string;
|
storyURL: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* siteID is the Site that the newly created Story was created on.
|
||||||
|
*/
|
||||||
|
siteID: string;
|
||||||
}
|
}
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export type StoryCreatedCoralEventPayload = CoralEventPayload<
|
|||||||
{
|
{
|
||||||
storyID: string;
|
storyID: string;
|
||||||
storyURL: string;
|
storyURL: string;
|
||||||
|
siteID: string;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,21 @@ export function generateSignatures(
|
|||||||
.join(",");
|
.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CoralWebhookEventPayload = CoralEventPayload & {
|
||||||
|
/**
|
||||||
|
* tenantID is the ID of the Tenant that this event originated at.
|
||||||
|
*/
|
||||||
|
readonly tenantID: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tenantDomain is the domain that is associated with this Tenant that this event originated at.
|
||||||
|
*/
|
||||||
|
readonly tenantDomain: string;
|
||||||
|
};
|
||||||
|
|
||||||
export function generateFetchOptions(
|
export function generateFetchOptions(
|
||||||
endpoint: Pick<Endpoint, "signingSecrets">,
|
endpoint: Pick<Endpoint, "signingSecrets">,
|
||||||
data: CoralEventPayload,
|
data: CoralWebhookEventPayload,
|
||||||
now: Date
|
now: Date
|
||||||
): FetchOptions {
|
): FetchOptions {
|
||||||
// Serialize the body and signature to include in the request.
|
// Serialize the body and signature to include in the request.
|
||||||
@@ -151,7 +163,11 @@ export function createJobProcessor({
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
// Get the fetch options.
|
// Get the fetch options.
|
||||||
const options = generateFetchOptions(endpoint, event, now);
|
const options = generateFetchOptions(
|
||||||
|
endpoint,
|
||||||
|
{ ...event, tenantID, tenantDomain: tenant.domain },
|
||||||
|
now
|
||||||
|
);
|
||||||
|
|
||||||
// Send the request.
|
// Send the request.
|
||||||
const startedSendingAt = getNow();
|
const startedSendingAt = getNow();
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export async function findOrCreate(
|
|||||||
StoryCreatedCoralEvent.publish(broker, {
|
StoryCreatedCoralEvent.publish(broker, {
|
||||||
storyID: story.id,
|
storyID: story.id,
|
||||||
storyURL: story.url,
|
storyURL: story.url,
|
||||||
|
siteID: story.siteID,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +223,7 @@ export async function create(
|
|||||||
StoryCreatedCoralEvent.publish(broker, {
|
StoryCreatedCoralEvent.publish(broker, {
|
||||||
storyID: story.id,
|
storyID: story.id,
|
||||||
storyURL: story.url,
|
storyURL: story.url,
|
||||||
|
siteID: site.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
return story;
|
return story;
|
||||||
|
|||||||
Reference in New Issue
Block a user