mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
fix: Notifications sent for insignificant changes
This commit is contained in:
1 parent
854fbca420
commit
76ada1acbc
5 files changed
+24
-39
No files matched your search
@@ -237,6 +237,7 @@
|
||||
"tiny-cookie": "^2.5.1",
|
||||
"tmp": "^0.2.3",
|
||||
"turndown": "^7.2.0",
|
||||
"ukkonen": "^2.1.0",
|
||||
"umzug": "^3.8.2",
|
||||
"utility-types": "^3.11.0",
|
||||
"uuid": "^8.3.2",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { JSDOM } from "jsdom";
|
||||
import { Node } from "prosemirror-model";
|
||||
import ukkonen from "ukkonen";
|
||||
import { updateYFragment, yDocToProsemirrorJSON } from "y-prosemirror";
|
||||
import * as Y from "yjs";
|
||||
import textBetween from "@shared/editor/lib/textBetween";
|
||||
@@ -483,20 +484,22 @@ export class DocumentHelper {
|
||||
*
|
||||
* @param document The document to compare
|
||||
* @param other The other document to compare
|
||||
* @param threshold The threshold for the change in characters
|
||||
* @returns True if the text content is equal
|
||||
*/
|
||||
public static isTextContentEqual(
|
||||
public static isChangeOverThreshold(
|
||||
before: Document | Revision | null,
|
||||
after: Document | Revision | null
|
||||
after: Document | Revision | null,
|
||||
threshold: number
|
||||
) {
|
||||
if (!before || !after) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
before.title === after.title &&
|
||||
this.toMarkdown(before) === this.toMarkdown(after)
|
||||
);
|
||||
const first = before.title + this.toPlainText(before);
|
||||
const second = after.title + this.toPlainText(after);
|
||||
const distance = ukkonen(first, second);
|
||||
return distance > threshold;
|
||||
}
|
||||
|
||||
private static textSerializers = getTextSerializers(schema);
|
||||
|
||||
@@ -28,10 +28,10 @@ export default class RevisionCreatedNotificationsTask extends BaseTask<RevisionE
|
||||
const before = await revision.before();
|
||||
|
||||
// If the content looks the same, don't send notifications
|
||||
if (DocumentHelper.isTextContentEqual(before, revision)) {
|
||||
if (!DocumentHelper.isChangeOverThreshold(before, revision, 5)) {
|
||||
Logger.info(
|
||||
"processor",
|
||||
`suppressing notifications as update has no visual changes`
|
||||
`suppressing notifications as update has insignificant changes`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -19,3 +19,7 @@ declare module "@joplin/turndown-plugin-gfm" {
|
||||
export const taskListItems: Plugin;
|
||||
export const gfm: Plugin;
|
||||
}
|
||||
|
||||
declare module "ukkonen" {
|
||||
export default function ukkonen(first: string, second: string): number;
|
||||
}
|
||||
@@ -768,16 +768,7 @@
|
||||
"@babel/traverse" "^7.25.9"
|
||||
semver "^6.3.1"
|
||||
|
||||
"@babel/helper-create-regexp-features-plugin@^7.18.6":
|
||||
version "7.25.7"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.25.7.tgz#dcb464f0e2cdfe0c25cc2a0a59c37ab940ce894e"
|
||||
integrity sha512-byHhumTj/X47wJ6C6eLpK7wW/WBEcnUeb7D0FNc/jFQnQVw7DOso3Zz5u9x/zLrFVkHa89ZGDbkAa1D54NdrCQ==
|
||||
dependencies:
|
||||
"@babel/helper-annotate-as-pure" "^7.25.7"
|
||||
regexpu-core "^6.1.1"
|
||||
semver "^6.3.1"
|
||||
|
||||
"@babel/helper-create-regexp-features-plugin@^7.25.9":
|
||||
"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.25.9":
|
||||
version "7.26.3"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.26.3.tgz#5169756ecbe1d95f7866b90bb555b022595302a0"
|
||||
integrity sha512-G7ZRb40uUgdKOQqPLjfD12ZmGA54PzqDFUv2BKImnC9QIfGhIHKvVML0oN8IUiDq4iRqpq74ABpvOaerfWdong==
|
||||
@@ -1078,20 +1069,13 @@
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.14.5"
|
||||
|
||||
"@babel/plugin-syntax-typescript@^7.25.9":
|
||||
"@babel/plugin-syntax-typescript@^7.25.9", "@babel/plugin-syntax-typescript@^7.7.2":
|
||||
version "7.25.9"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz#67dda2b74da43727cf21d46cf9afef23f4365399"
|
||||
integrity sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.25.9"
|
||||
|
||||
"@babel/plugin-syntax-typescript@^7.7.2":
|
||||
version "7.24.1"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.24.1.tgz#b3bcc51f396d15f3591683f90239de143c076844"
|
||||
integrity sha512-Yhnmvy5HZEnHUty6i++gcfH1/l68AHnItFHnaCv6hn9dNh0hQvvQJsxpi4BMBFN5DLeHBuucT/0DgzXif/OyRw==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.24.0"
|
||||
|
||||
"@babel/plugin-syntax-unicode-sets-regex@^7.18.6":
|
||||
version "7.18.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz#d49a3b3e6b52e5be6740022317580234a6a47357"
|
||||
@@ -13524,19 +13508,7 @@ regexpp@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
||||
integrity "sha1-BCWido2PI7rXDKS5BGH6LxIT4bI= sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg=="
|
||||
|
||||
regexpu-core@^6.1.1:
|
||||
version "6.1.1"
|
||||
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-6.1.1.tgz#b469b245594cb2d088ceebc6369dceb8c00becac"
|
||||
integrity sha512-k67Nb9jvwJcJmVpw0jPttR1/zVfnKf8Km0IPatrU/zJ5XeG3+Slx0xLXs9HByJSzXzrlz5EDvN6yLNMDc2qdnw==
|
||||
dependencies:
|
||||
regenerate "^1.4.2"
|
||||
regenerate-unicode-properties "^10.2.0"
|
||||
regjsgen "^0.8.0"
|
||||
regjsparser "^0.11.0"
|
||||
unicode-match-property-ecmascript "^2.0.0"
|
||||
unicode-match-property-value-ecmascript "^2.1.0"
|
||||
|
||||
regexpu-core@^6.2.0:
|
||||
regexpu-core@^6.1.1, regexpu-core@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-6.2.0.tgz#0e5190d79e542bf294955dccabae04d3c7d53826"
|
||||
integrity sha512-H66BPQMrv+V16t8xtmq+UC0CBpiTBA60V8ibS1QVReIp8T1z8hwFxqcGzm9K6lgsN7sB5edVH8a+ze6Fqm4weA==
|
||||
@@ -15139,6 +15111,11 @@ uid2@0.0.3, uid2@0.0.x:
|
||||
resolved "https://registry.yarnpkg.com/uid2/-/uid2-0.0.3.tgz#483126e11774df2f71b8b639dcd799c376162b82"
|
||||
integrity "sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I= sha512-5gSP1liv10Gjp8cMEnFd6shzkL/D6W1uhXSFNCxDC+YI8+L8wkCYCbJ7n77Ezb4wE/xzMogecE+DtamEe9PZjg=="
|
||||
|
||||
ukkonen@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/ukkonen/-/ukkonen-2.1.0.tgz#7af741397e603462290aa5d4e65e514f400b29f7"
|
||||
integrity sha512-unACtiJBMpL5Q+JKEBYtB88DVClP4Ch42NFkuj7Ck7jcJ4UKkkfvvfGQ2WeaMeuq7OIGLkbm0X7YN+TGP9C5bw==
|
||||
|
||||
umzug@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/umzug/-/umzug-2.3.0.tgz#0ef42b62df54e216b05dcaf627830a6a8b84a184"
|
||||
|
||||
Reference in new issue
Block a user