mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
bug fixes
This commit is contained in:
@@ -176,12 +176,9 @@ function Notifications() {
|
||||
NotificationChannelType.Slack,
|
||||
]) {
|
||||
const shouldEnable = channels.includes(channel);
|
||||
const currentlyEnabled = user.subscribedToEventType(
|
||||
eventType,
|
||||
channel
|
||||
);
|
||||
const enabled = user.subscribedToEventType(eventType, channel);
|
||||
|
||||
if (shouldEnable !== currentlyEnabled) {
|
||||
if (shouldEnable !== enabled) {
|
||||
await user.setNotificationEventType(
|
||||
eventType,
|
||||
shouldEnable,
|
||||
|
||||
@@ -19,21 +19,25 @@ type Props = {
|
||||
function ChannelSelector({ value, onChange, slackDisabled = false }: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const channels = React.useMemo(
|
||||
() => [
|
||||
const channels = React.useMemo(() => {
|
||||
const availableChannels = [
|
||||
{
|
||||
key: NotificationChannelType.Email,
|
||||
label: t("Email"),
|
||||
icon: <EmailIcon size={16} />,
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (!slackDisabled) {
|
||||
availableChannels.push({
|
||||
key: NotificationChannelType.Slack,
|
||||
label: t("Slack"),
|
||||
icon: <FontAwesomeIcon icon={faSlack} size="xs" />,
|
||||
},
|
||||
],
|
||||
[t, slackDisabled]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return availableChannels;
|
||||
}, [t, slackDisabled]);
|
||||
|
||||
const handleToggle = React.useCallback(
|
||||
(channelType: NotificationChannelType) => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git a/node_modules/chat/package.json b/node_modules/chat/package.json
|
||||
index 89e4e44..24b552d 100644
|
||||
index 89e4e44..7cfcb8f 100644
|
||||
--- a/node_modules/chat/package.json
|
||||
+++ b/node_modules/chat/package.json
|
||||
@@ -9,15 +9,18 @@
|
||||
@@ -9,7 +9,8 @@
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -12,19 +12,7 @@ index 89e4e44..24b552d 100644
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
"types": "./dist/jsx-runtime.d.ts",
|
||||
- "import": "./dist/jsx-runtime.js"
|
||||
+ "import": "./dist/jsx-runtime.js",
|
||||
+ "default": "./dist/jsx-runtime.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
"types": "./dist/jsx-runtime.d.ts",
|
||||
- "import": "./dist/jsx-runtime.js"
|
||||
+ "import": "./dist/jsx-runtime.js",
|
||||
+ "default": "./dist/jsx-runtime.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -68,4 +71,4 @@
|
||||
@@ -68,4 +69,4 @@
|
||||
"typecheck": "tsc --noEmit",
|
||||
"clean": "rm -rf dist docs"
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
NotificationEventDefaults,
|
||||
UserRole,
|
||||
DocumentPermission,
|
||||
IntegrationType,
|
||||
} from "@shared/types";
|
||||
import { UserRoleHelper } from "@shared/utils/UserRoleHelper";
|
||||
import { stringToColor } from "@shared/utils/color";
|
||||
@@ -74,6 +75,7 @@ import IsUrlOrRelativePath from "./validators/IsUrlOrRelativePath";
|
||||
import Length from "./validators/Length";
|
||||
import NotContainsUrl from "./validators/NotContainsUrl";
|
||||
import { SkipChangeset } from "./decorators/Changeset";
|
||||
import Integration from "./Integration";
|
||||
|
||||
/**
|
||||
* Flags that are available for setting on the user.
|
||||
@@ -416,8 +418,6 @@ class User extends ParanoidModel<
|
||||
* @returns The Slack user ID or null.
|
||||
*/
|
||||
public getSlackUserId = async (): Promise<string | null> => {
|
||||
const { Integration } = await import("./index");
|
||||
const { IntegrationType } = await import("@shared/types");
|
||||
const integration = await Integration.findOne({
|
||||
where: {
|
||||
userId: this.id,
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
NotificationEventType,
|
||||
MentionType,
|
||||
SubscriptionType,
|
||||
NotificationChannelType,
|
||||
} from "@shared/types";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import type { Document, Collection } from "@server/models";
|
||||
@@ -159,11 +160,13 @@ export default class NotificationHelper {
|
||||
notificationType,
|
||||
actorId,
|
||||
disableAccessCheck = false,
|
||||
channel = NotificationChannelType.Email,
|
||||
}: {
|
||||
document: Document;
|
||||
notificationType: NotificationEventType;
|
||||
actorId: string;
|
||||
disableAccessCheck?: boolean;
|
||||
channel?: NotificationChannelType;
|
||||
}): Promise<User[]> => {
|
||||
let recipients: User[];
|
||||
|
||||
@@ -175,7 +178,11 @@ export default class NotificationHelper {
|
||||
},
|
||||
teamId: document.teamId,
|
||||
notificationSettings: {
|
||||
[notificationType]: true,
|
||||
[Op.and]: {
|
||||
[notificationType]: {
|
||||
[channel]: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import { paragraph, root, strong, text, link } from "chat";
|
||||
* Listens for notification.create events and sends Slack DMs to users
|
||||
* who have linked their Slack accounts and enabled Slack notifications.
|
||||
*/
|
||||
export default class SlackNotificationsProcessor extends BaseProcessor {
|
||||
export default class SlackNotificationProcessor extends BaseProcessor {
|
||||
static applicableEvents: Event["name"][] = ["notifications.create"];
|
||||
|
||||
async perform(event: NotificationEvent) {
|
||||
@@ -508,6 +508,7 @@ export enum NotificationChannelType {
|
||||
App = "app",
|
||||
Email = "email",
|
||||
Chat = "chat",
|
||||
Slack = "slack",
|
||||
}
|
||||
|
||||
export type NotificationData = {
|
||||
|
||||
Reference in New Issue
Block a user