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, prohibitMoved: true,
limit: { limit: {
duration: ms('1minute'), duration: ms('1hour'),
max: 5, max: 300,
minInterval: ms('1sec'),
}, },
kind: 'write:notes', kind: 'write:notes',

View file

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

View file

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

View file

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

View file

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