[CORL-687] Webhooks (#2738)

* feat: initial webhook impl

* feat: added support for key rotation

* feat: harmonized fetcher

* feat: added expired secrets cleaning

* feat: event system refactor

* feat: added story event

* feat: simplfiied webhook handler

* feat: added ref's to locations where user events can be added

* feat: added UI to support webhooks

* fix: renaming some Webhook -> WebhookEndpoint

* fix: review comments to adjuist flow

* feat: added localizations

* fix: linting, updated snapshots

* fix: adapted for new fluent

* fix: rearranged folders

* fix: linting

* feat: added webhooks documentation

* feat: improved toc generation

* feat: added some tests to webhooks

* fix: chain transition hooks

* feat: added tests around webhook ui

* fix: renamed events

* fix: adjusted circle markdown linting

* fix: adjusted doctoc script call

* review: review fixes

* review: review comments

* review: adjusted signing secret confirmation

* review: adjusted styles to harmonize button usage

* fix: updated snapshots and tests

* review: move form out of webhooks

Moved the form out of the webhooks by relocating the layout used for the
route associated with the configure routes.

* fix: fixed bugs and snapshots with tests

* feat: revised slack message format to use block api

* fix: fixed a small text bug

Co-authored-by: Vinh <vinh@vinh.tech>
Co-authored-by: Kim Gardner <kgardnr@gmail.com>
This commit is contained in:
Wyatt Johnson
2020-02-18 13:25:48 -05:00
committed by GitHub
co-authored by Vinh Kim Gardner
parent 34ba2da88d
commit e42c2b925d
137 changed files with 5633 additions and 1020 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
import { Db } from "mongodb";
import { Config } from "coral-server/config";
import { Publisher } from "coral-server/graph/subscriptions/publisher";
import { CoralEventPublisherBroker } from "coral-server/events/publisher";
import { Tenant } from "coral-server/models/tenant";
import { moderate } from "coral-server/services/comments/moderation";
import { notifyPerspectiveModerationDecision } from "coral-server/services/perspective";
@@ -15,7 +15,7 @@ const approveComment = async (
mongo: Db,
redis: AugmentedRedis,
config: Config,
publisher: Publisher,
broker: CoralEventPublisherBroker,
tenant: Tenant,
commentID: string,
commentRevisionID: string,
@@ -44,7 +44,7 @@ const approveComment = async (
});
// Publish changes to the event publisher.
await publishChanges(publisher, {
await publishChanges(broker, {
...result,
...counts,
moderatorID,
+5 -5
View File
@@ -8,7 +8,7 @@ import {
CoralError,
StoryNotFoundError,
} from "coral-server/errors";
import { Publisher } from "coral-server/graph/subscriptions/publisher";
import { CoralEventPublisherBroker } from "coral-server/events/publisher";
import logger from "coral-server/logger";
import {
encodeActionCounts,
@@ -59,7 +59,7 @@ export default async function create(
mongo: Db,
redis: AugmentedRedis,
config: Config,
publisher: Publisher,
broker: CoralEventPublisherBroker,
tenant: Tenant,
author: User,
input: CreateComment,
@@ -233,19 +233,19 @@ export default async function create(
});
// Publish changes to the event publisher.
await publishChanges(publisher, {
await publishChanges(broker, {
...counts,
after: comment,
});
// If this is a reply, publish it.
if (input.parentID) {
publishCommentReplyCreated(publisher, comment);
publishCommentReplyCreated(broker, comment);
}
// If this comment is visible (and not a reply), publish it.
if (!input.parentID && hasPublishedStatus(comment)) {
publishCommentCreated(publisher, comment);
publishCommentCreated(broker, comment);
}
return comment;
+3 -3
View File
@@ -4,7 +4,7 @@ import { Db } from "mongodb";
import { Omit } from "coral-common/types";
import { Config } from "coral-server/config";
import { CommentNotFoundError, StoryNotFoundError } from "coral-server/errors";
import { Publisher } from "coral-server/graph/subscriptions/publisher";
import { CoralEventPublisherBroker } from "coral-server/events/publisher";
import logger from "coral-server/logger";
import {
encodeActionCounts,
@@ -57,7 +57,7 @@ export default async function edit(
mongo: Db,
redis: AugmentedRedis,
config: Config,
publisher: Publisher,
broker: CoralEventPublisherBroker,
tenant: Tenant,
author: User,
input: EditComment,
@@ -188,7 +188,7 @@ export default async function edit(
});
// Publish changes to the event publisher.
await publishChanges(publisher, {
await publishChanges(broker, {
...result,
...counts,
});
@@ -1,4 +1,4 @@
import { Publisher } from "coral-server/graph/subscriptions/publisher";
import { CoralEventPublisherBroker } from "coral-server/events/publisher";
import {
Comment,
CommentModerationQueueCounts,
@@ -19,17 +19,17 @@ interface PublishChangesInput {
}
export default async function publishChanges(
publish: Publisher,
broker: CoralEventPublisherBroker,
input: PublishChangesInput
) {
// Publish changes.
publishModerationQueueChanges(publish, input.moderationQueue, input.after);
publishModerationQueueChanges(broker, input.moderationQueue, input.after);
// If this was a change, and it has a "before" state for the comment, process
// those updates too.
if (input.before) {
publishCommentStatusChanges(
publish,
broker,
input.before.status,
input.after.status,
input.after.id,
@@ -37,7 +37,7 @@ export default async function publishChanges(
);
if (hasModeratorStatus(input.before) && hasPublishedStatus(input.after)) {
publishCommentReleased(publish, input.after);
publishCommentReleased(broker, input.after);
}
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { Db } from "mongodb";
import { Config } from "coral-server/config";
import { Publisher } from "coral-server/graph/subscriptions/publisher";
import { CoralEventPublisherBroker } from "coral-server/events/publisher";
import { hasTag } from "coral-server/models/comment";
import { Tenant } from "coral-server/models/tenant";
import { removeTag } from "coral-server/services/comments";
@@ -20,7 +20,7 @@ const rejectComment = async (
mongo: Db,
redis: AugmentedRedis,
config: Config,
publisher: Publisher,
broker: CoralEventPublisherBroker,
tenant: Tenant,
commentID: string,
commentRevisionID: string,
@@ -49,7 +49,7 @@ const rejectComment = async (
});
// Publish changes to the event publisher.
await publishChanges(publisher, {
await publishChanges(broker, {
...result,
...counts,
moderatorID,