mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
fix(invites): list invites via per-group KV index instead of kv.list
Cloudflare KV's list operation is eventually consistent and can lag
behind a fresh write, so pending invites were invisible right after
creation (GET /admin/api/groups/:id/invites returned {invites: []}).
Keep a per-group token index (invite:group:{id}) updated on create,
revoke, accept and expiry; the members panel also inserts the freshly
created invite into the list immediately and copies the absolute link.
This commit is contained in:
parent
ce9f6147f1
commit
a0e15975df
4 changed files with 76 additions and 8 deletions
|
|
@ -162,9 +162,25 @@ async function createInvite(): Promise<void> {
|
|||
formError.value = "";
|
||||
try {
|
||||
const url = await invitesApi.create(props.group.id, inviteRole.value);
|
||||
const token = url.split("token=")[1] ?? "";
|
||||
if (token) {
|
||||
invites.value = [
|
||||
{
|
||||
token,
|
||||
groupId: props.group.id,
|
||||
role: inviteRole.value,
|
||||
expiresAt: Date.now() + 7 * 86400_000,
|
||||
createdBy: "",
|
||||
},
|
||||
...invites.value,
|
||||
];
|
||||
}
|
||||
copyText(`${window.location.origin}${url}`);
|
||||
copiedToken.value = token;
|
||||
window.setTimeout(() => {
|
||||
copiedToken.value = "";
|
||||
}, 2000);
|
||||
await loadInvites();
|
||||
copyText(url);
|
||||
copiedToken.value = "";
|
||||
} catch (err) {
|
||||
formError.value = err instanceof Error ? err.message : String(err);
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue