mirror of
https://github.com/outline/outline.git
synced 2026-11-28 00:09:58 +03:00
* Improve scoping of public share subscriptions
* fix: Add missing transaction, includeChildDocuments check, and test documentId
- Pass { transaction } to ShareSubscription.create in the subscribe handler
so the insert runs atomically with the duplicate-check findOne/lock
- Skip ancestor-scoped subscription notifications when the share has
includeChildDocuments=false, preventing notifications for inaccessible docs
- Add required documentId field to all share subscription tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: Resolve type error for nullable share.documentId in tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* JSDoc
* Hide subscription option for logged-in users
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { useEffect } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useHistory } from "react-router-dom";
|
|
import { toast } from "sonner";
|
|
import { QueryNotices } from "@shared/types";
|
|
import useQuery from "./useQuery";
|
|
|
|
/**
|
|
* Display a toast message based on a notice in the query string. This is usually
|
|
* used when redirecting from an external source to the client, such as OAuth,
|
|
* or emails.
|
|
*/
|
|
export default function useQueryNotices() {
|
|
const query = useQuery();
|
|
const history = useHistory();
|
|
const { t } = useTranslation();
|
|
const notice = query.get("notice") as QueryNotices;
|
|
|
|
useEffect(() => {
|
|
let message: string | undefined;
|
|
|
|
switch (notice) {
|
|
case QueryNotices.UnsubscribeDocument: {
|
|
message = t("Unsubscribed from document");
|
|
break;
|
|
}
|
|
case QueryNotices.UnsubscribeCollection: {
|
|
message = t("Unsubscribed from collection");
|
|
break;
|
|
}
|
|
case QueryNotices.Subscribed: {
|
|
message = t("Subscription successful");
|
|
break;
|
|
}
|
|
default:
|
|
}
|
|
|
|
if (message) {
|
|
toast.success(message);
|
|
|
|
// Remove the notice param from the URL to prevent duplicate toasts
|
|
const params = new URLSearchParams(window.location.search);
|
|
params.delete("notice");
|
|
const search = params.toString();
|
|
history.replace({
|
|
pathname: window.location.pathname,
|
|
search: search ? `?${search}` : "",
|
|
});
|
|
}
|
|
}, [t, notice, history]);
|
|
}
|