merge: tweak the rate limit for notes/create and other improvements (!548)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/548

Closes #467 and #468

Approved-by: fEmber <acomputerdog@gmail.com>
Approved-by: Marie <marie@kaifa.ch>
This commit is contained in:
dakkar 2024-06-13 07:58:28 +00:00
commit 853058e78d
5 changed files with 31 additions and 14 deletions

View file

@ -30,8 +30,9 @@ export const meta = {
prohibitMoved: true,
limit: {
duration: ms('1minute'),
max: 5,
duration: ms('1hour'),
max: 300,
minInterval: ms('1sec'),
},
kind: 'write:notes',

View file

@ -336,7 +336,7 @@ let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'(q)': () => { if (canRenote.value && !renoted.value && !renoting) renote(defaultStore.state.visibilityOnBoost); },
'up|k|shift+tab': focusBefore,
'down|j|tab': focusAfter,
'esc': blur,
@ -414,6 +414,8 @@ if (!props.mock) {
}
function boostVisibility() {
if (renoting) return;
if (!defaultStore.state.showVisibilitySelectorOnBoost) {
renote(defaultStore.state.visibilityOnBoost);
} else {
@ -425,6 +427,8 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
pleaseLogin();
showMovedDialog();
renoting = true;
if (appearNote.value.channel) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -441,7 +445,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
}
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
@ -460,7 +464,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => renoting = false);
}).finally(() => { renoting = false; });
}
}
}

View file

@ -342,7 +342,7 @@ let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'(q)': () => { if (canRenote.value && !renoted.value && !renoting) renote(defaultStore.state.visibilityOnBoost); },
'esc': blur,
'm|o': () => showMenu(true),
's': () => showContent.value !== showContent.value,
@ -434,6 +434,8 @@ useTooltip(quoteButton, async (showing) => {
});
function boostVisibility() {
if (renoting) return;
if (!defaultStore.state.showVisibilitySelectorOnBoost) {
renote(defaultStore.state.visibilityOnBoost);
} else {
@ -445,6 +447,8 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
pleaseLogin();
showMovedDialog();
renoting = true;
if (appearNote.value.channel) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -460,7 +464,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -477,7 +481,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
}
}

View file

@ -335,7 +335,7 @@ let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'(q)': () => { if (canRenote.value && !renoted.value && !renoting) renote(defaultStore.state.visibilityOnBoost); },
'up|k|shift+tab': focusBefore,
'down|j|tab': focusAfter,
'esc': blur,
@ -413,6 +413,8 @@ if (!props.mock) {
}
function boostVisibility() {
if (renoting) return;
if (!defaultStore.state.showVisibilitySelectorOnBoost) {
renote(defaultStore.state.visibilityOnBoost);
} else {
@ -424,6 +426,8 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
pleaseLogin();
showMovedDialog();
renoting = true;
if (appearNote.value.channel) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -440,7 +444,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
}
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
@ -459,7 +463,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
}
}
}

View file

@ -351,7 +351,7 @@ let renoting = false;
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
'(q)': () => { if (canRenote && !renoted.value && !renoting) { renoting = true; renote(appearNote.value.visibility) } },
'(q)': () => { if (canRenote.value && !renoted.value && !renoting) renote(defaultStore.state.visibilityOnBoost); },
'esc': blur,
'm|o': () => showMenu(true),
's': () => showContent.value !== showContent.value,
@ -443,6 +443,8 @@ useTooltip(quoteButton, async (showing) => {
});
function boostVisibility() {
if (renoting) return;
if (!defaultStore.state.showVisibilitySelectorOnBoost) {
renote(defaultStore.state.visibilityOnBoost);
} else {
@ -454,6 +456,8 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
pleaseLogin();
showMovedDialog();
renoting = true;
if (appearNote.value.channel) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -469,7 +473,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
} else if (!appearNote.value.channel || appearNote.value.channel.allowRenoteToExternal) {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -486,7 +490,7 @@ function renote(visibility: Visibility, localOnly: boolean = false) {
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
}).finally(() => { renoting = false });
}).finally(() => { renoting = false; });
}
}