Events 3.1.0, Accounts 1.2.0, contracts 1.9.0: the move needs Accounts' email
A church moved sign-in to Accounts without email set up there: codes and password links couldn't be sent, sign-in failed with a 500, nobody could get in. - contracts 1.9.0: messaging.status/test/set (SMTP, WAWP; secrets sealed); people.ensure answers emailSent. - Accounts 1.2.0: SendError instead of a 500; WhatsApp codes fall back to email; forgot password says email isn't set up; setup only offers methods that work; messaging.* (test, save only what worked); test WhatsApp in admin; WAWP from .env. - Events 3.1.0: Settings -> Sign-in shows what Accounts can send and copies this site's SMTP/WAWP into it (secrets stay on the server), test then save; Move disabled and refused (EMAIL_NOT_READY) without email. Tests: Accounts 54, contracts 218, Events 774, test:accounts 16 (also on Postgres). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-frontend",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Mail, MessageCircle } from "lucide-react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { apiV2, type V2Result } from "@/lib/apiV2";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
|
||||
type Overview = V2Result<"/settings/sign-in/messaging", "get">["data"];
|
||||
type Answer = V2Result<"/settings/sign-in/messaging", "post">["data"];
|
||||
type Result = { ok: boolean; error: string | null; saved: boolean } | null;
|
||||
|
||||
/**
|
||||
* Email and WhatsApp for the church's Accounts (3.1.0): Accounts sends its own sign-in codes and
|
||||
* password links, with its own settings, so they're set up before sign-in moves there. This site's
|
||||
* own settings are offered to copy (its password and WAWP token stay on the server: leave the field
|
||||
* blank to use them), tested through Accounts, and saved there only once the test worked.
|
||||
*/
|
||||
export function AccountsMessaging({ onReady }: { onReady: (ready: { email: boolean; whatsapp: boolean }) => void }) {
|
||||
const { token, user } = useAuth();
|
||||
const [data, setData] = useState<Overview | null>(null);
|
||||
const [err, setErr] = useState<string | null>(null);
|
||||
const [email, setEmail] = useState({ host: "", port: "587", secure: false, user: "", from: "", pass: "", to: "" });
|
||||
const [wa, setWa] = useState({ instanceId: "", accessToken: "", to: "" });
|
||||
const [emailResult, setEmailResult] = useState<Result>(null);
|
||||
const [waResult, setWaResult] = useState<Result>(null);
|
||||
const [testedEmail, setTestedEmail] = useState<string | null>(null);
|
||||
const [testedWa, setTestedWa] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
|
||||
const load = () => {
|
||||
if (!token) return;
|
||||
apiV2("get", "/settings/sign-in/messaging", { authToken: token })
|
||||
.then(({ data: d }) => {
|
||||
setData(d);
|
||||
if (d.accounts) onReady({ email: d.accounts.email.ready, whatsapp: d.accounts.whatsapp.ready });
|
||||
const e = d.events.email;
|
||||
if (e) setEmail((x) => (x.host ? x : { ...x, host: e.host, port: String(e.port), secure: e.secure, user: e.user, from: e.from }));
|
||||
if (d.events.whatsapp) setWa((x) => (x.instanceId ? x : { ...x, instanceId: d.events.whatsapp!.instanceId }));
|
||||
})
|
||||
.catch((e) => setErr(errorMessage(e) || "Could not load the email settings."));
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- once per sign-in
|
||||
useEffect(load, [token]);
|
||||
useEffect(() => {
|
||||
setEmail((x) => (x.to ? x : { ...x, to: user?.email || "" }));
|
||||
setWa((x) => (x.to ? x : { ...x, to: user?.phoneNumber || "" }));
|
||||
}, [user]);
|
||||
|
||||
if (!token) return null;
|
||||
if (!data) return err ? <p className="text-sm text-red-700">{err}</p> : <p className="text-sm text-gray-500">Loading email settings…</p>;
|
||||
|
||||
const emailKey = JSON.stringify({ ...email, to: undefined });
|
||||
const waKey = JSON.stringify({ ...wa, to: undefined });
|
||||
const emailBody = () => ({ email: { host: email.host, port: parseInt(email.port, 10) || 587, secure: email.secure, user: email.user, from: email.from, pass: email.pass || null, to: email.to } });
|
||||
const waBody = () => ({ whatsapp: { instanceId: wa.instanceId, accessToken: wa.accessToken || null, to: wa.to } });
|
||||
|
||||
const run = async (key: string, save: boolean, body: object, after: (a: Answer) => void) => {
|
||||
setBusy(key);
|
||||
setErr(null);
|
||||
try {
|
||||
const { data: a } = save
|
||||
? await apiV2("post", "/settings/sign-in/messaging", { authToken: token, body: body as never })
|
||||
: await apiV2("post", "/settings/sign-in/messaging/test", { authToken: token, body: body as never });
|
||||
after(a);
|
||||
setData((d) => (d ? { ...d, accounts: { email: a.status.email, whatsapp: a.status.whatsapp }, accountsError: null } : d));
|
||||
onReady({ email: a.status.email.ready, whatsapp: a.status.whatsapp.ready });
|
||||
} catch (e) {
|
||||
setErr(errorMessage(e) || "That didn't work.");
|
||||
}
|
||||
setBusy(null);
|
||||
};
|
||||
|
||||
const acc = data.accounts;
|
||||
const input = "w-full rounded-lg border px-3 py-2 text-sm";
|
||||
const line = (r: Result, what: string) => r && (
|
||||
<p className={`text-sm ${r.ok ? "text-green-800" : "text-red-800"}`} role="status">
|
||||
{r.ok ? (r.saved ? `Saved in Accounts: ${what} works there now.` : `The test ${what} went. Check it arrived, then save.`) : `The test didn't work: ${r.error}`}
|
||||
</p>
|
||||
);
|
||||
|
||||
return (
|
||||
<section className="border rounded-xl p-4 space-y-4">
|
||||
<div>
|
||||
<h3 className="font-medium">Email and WhatsApp for the church's sign-in</h3>
|
||||
<p className="text-sm text-gray-600">Accounts sends sign-in codes and password links itself, with its own settings. Without email there, nobody can sign in after the move.</p>
|
||||
</div>
|
||||
{data.accountsError ? (
|
||||
<p className="text-sm text-red-700">Accounts can't be reached: {data.accountsError}</p>
|
||||
) : acc && (
|
||||
<ul className="text-sm space-y-1">
|
||||
<li className="flex items-center gap-2"><Mail className="h-4 w-4" aria-hidden /> Email: {acc.email.ready ? <span className="text-green-800">works{acc.email.from ? ` (from ${acc.email.from})` : ""}</span> : <span className="font-medium text-red-800">not set up</span>}</li>
|
||||
<li className="flex items-center gap-2"><MessageCircle className="h-4 w-4" aria-hidden /> WhatsApp: {acc.whatsapp.ready ? <span className="text-green-800">works</span> : <span className="text-amber-800">not set up (WhatsApp codes then go by email)</span>}</li>
|
||||
</ul>
|
||||
)}
|
||||
{err && <p className="text-sm text-red-800">{err}</p>}
|
||||
|
||||
<details open={!!acc && !acc.email.ready} className="rounded-lg border p-3">
|
||||
<summary className="cursor-pointer text-sm font-medium">{acc?.email.ready ? "Change Accounts' email" : "Set up Accounts' email"}{data.events.email ? " (copied from this site)" : ""}</summary>
|
||||
<div className="mt-3 grid gap-3 md:grid-cols-2">
|
||||
<label className="text-sm">SMTP server<input className={input} value={email.host} onChange={(e) => setEmail({ ...email, host: e.target.value })} /></label>
|
||||
<label className="text-sm">Port<input className={input} inputMode="numeric" value={email.port} onChange={(e) => setEmail({ ...email, port: e.target.value })} /></label>
|
||||
<label className="text-sm">User name<input className={input} value={email.user} onChange={(e) => setEmail({ ...email, user: e.target.value })} autoComplete="off" /></label>
|
||||
<label className="text-sm">Password<input className={input} type="password" value={email.pass} onChange={(e) => setEmail({ ...email, pass: e.target.value })} autoComplete="new-password" placeholder={data.events.email?.hasPass ? "Leave blank to use this site's password" : ""} /></label>
|
||||
<label className="text-sm">Send from<input className={input} value={email.from} onChange={(e) => setEmail({ ...email, from: e.target.value })} /></label>
|
||||
<label className="flex items-center gap-2 text-sm md:mt-6"><input type="checkbox" checked={email.secure} onChange={(e) => setEmail({ ...email, secure: e.target.checked })} /> TLS from the start (port 465)</label>
|
||||
<label className="text-sm md:col-span-2">Send the test email to<input className={input} type="email" value={email.to} onChange={(e) => setEmail({ ...email, to: e.target.value })} /></label>
|
||||
</div>
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
<button type="button" className="px-3 py-2 rounded-lg border text-sm" disabled={!!busy || !email.host || !email.to}
|
||||
onClick={() => run("email-test", false, emailBody(), (a) => { setEmailResult(a.email); if (a.email?.ok) setTestedEmail(emailKey); })}>
|
||||
{busy === "email-test" ? "Sending…" : "Send a test email"}
|
||||
</button>
|
||||
<button type="button" className="px-3 py-2 rounded-lg bg-brand-600 text-white text-sm disabled:opacity-50" disabled={!!busy || testedEmail !== emailKey}
|
||||
title={testedEmail !== emailKey ? "Send a test with these settings first" : undefined}
|
||||
onClick={() => run("email-save", true, emailBody(), (a) => setEmailResult(a.email))}>
|
||||
{busy === "email-save" ? "Saving…" : "Save in Accounts"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="mt-2">{line(emailResult, "email")}</div>
|
||||
</details>
|
||||
|
||||
<details className="rounded-lg border p-3">
|
||||
<summary className="cursor-pointer text-sm font-medium">{acc?.whatsapp.ready ? "Change Accounts' WhatsApp (WAWP)" : "Set up Accounts' WhatsApp (WAWP), optional"}{data.events.whatsapp ? " (copied from this site)" : ""}</summary>
|
||||
<div className="mt-3 grid gap-3 md:grid-cols-2">
|
||||
<label className="text-sm">WAWP instance id<input className={input} value={wa.instanceId} onChange={(e) => setWa({ ...wa, instanceId: e.target.value })} /></label>
|
||||
<label className="text-sm">WAWP access token<input className={input} type="password" value={wa.accessToken} onChange={(e) => setWa({ ...wa, accessToken: e.target.value })} autoComplete="new-password" placeholder={data.events.whatsapp?.hasToken ? "Leave blank to use this site's token" : ""} /></label>
|
||||
<label className="text-sm md:col-span-2">Send the test message to<input className={input} type="tel" value={wa.to} onChange={(e) => setWa({ ...wa, to: e.target.value })} placeholder="082 123 4567" /></label>
|
||||
</div>
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
<button type="button" className="px-3 py-2 rounded-lg border text-sm" disabled={!!busy || !wa.instanceId || !wa.to}
|
||||
onClick={() => run("wa-test", false, waBody(), (a) => { setWaResult(a.whatsapp); if (a.whatsapp?.ok) setTestedWa(waKey); })}>
|
||||
{busy === "wa-test" ? "Sending…" : "Send a test WhatsApp"}
|
||||
</button>
|
||||
<button type="button" className="px-3 py-2 rounded-lg bg-brand-600 text-white text-sm disabled:opacity-50" disabled={!!busy || testedWa !== waKey}
|
||||
title={testedWa !== waKey ? "Send a test with these settings first" : undefined}
|
||||
onClick={() => run("wa-save", true, waBody(), (a) => setWaResult(a.whatsapp))}>
|
||||
{busy === "wa-save" ? "Saving…" : "Save in Accounts"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="mt-2">{line(waResult, "WhatsApp")}</div>
|
||||
</details>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { LogIn } from "lucide-react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { apiV2, type V2Result } from "@/lib/apiV2";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { AccountsMessaging } from "@/components/admin/AccountsMessaging";
|
||||
|
||||
type Status = V2Result<"/settings/sign-in", "get">["data"];
|
||||
type Check = V2Result<"/settings/sign-in/check", "post">["data"];
|
||||
@@ -26,6 +27,8 @@ export function SignInTab({ active }: { active: boolean }) {
|
||||
const [keepAccountsNotices, setKeepAccountsNotices] = useState(false);
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null);
|
||||
// 3.1.0: what Accounts can send (the move needs its email).
|
||||
const [sending, setSending] = useState<{ email: boolean; whatsapp: boolean } | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!active || !token) return;
|
||||
@@ -98,6 +101,8 @@ export function SignInTab({ active }: { active: boolean }) {
|
||||
|
||||
{msg && <p className={`text-sm rounded-lg px-3 py-2 ${msg.ok ? "bg-green-50 text-green-800" : "bg-red-50 text-red-800"}`} role="status">{msg.text}</p>}
|
||||
|
||||
{status.accountsConnected && <AccountsMessaging onReady={setSending} />}
|
||||
|
||||
{status.mode === "accounts" ? (
|
||||
<section className="border rounded-xl p-4 space-y-3">
|
||||
<p className="text-sm"><span className="font-medium">Through Accounts</span>{status.accountsUrl ? <> at <a className="underline" href={status.accountsUrl} target="_blank" rel="noreferrer">{status.accountsUrl.replace(/^https?:\/\//, "")}</a></> : null}{status.movedAt ? `, since ${when(status.movedAt)}` : ""}.</p>
|
||||
@@ -158,7 +163,13 @@ export function SignInTab({ active }: { active: boolean }) {
|
||||
<label className="flex items-center gap-2 text-sm py-0.5 text-gray-400"><input type="radio" name="notice" disabled checked={!keepAccountsNotices} readOnly /> Use Cross Events' notice (remove Accounts' notice in Accounts first)</label>
|
||||
</fieldset>
|
||||
)}
|
||||
<button type="button" onClick={runMove} disabled={!!busy || (!!checked.noticeConflict && !keepAccountsNotices)} className="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium disabled:opacity-50">
|
||||
{!(sending?.email ?? checked.messaging.email) && (
|
||||
<p className="text-sm font-medium text-red-800">Set up Accounts' email above first (copy this site's, test it, save it): without it nobody could get a sign-in code or password link after the move.</p>
|
||||
)}
|
||||
{!!checked.messaging.whatsappTwoFactor && !(sending?.whatsapp ?? checked.messaging.whatsapp) && (
|
||||
<p className="text-sm text-amber-800">{checked.messaging.whatsappTwoFactor} people get their codes by WhatsApp, which Accounts can't send yet: their codes will go by email until you set it up.</p>
|
||||
)}
|
||||
<button type="button" onClick={runMove} disabled={!!busy || (!!checked.noticeConflict && !keepAccountsNotices) || !(sending?.email ?? checked.messaging.email)} className="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium disabled:opacity-50">
|
||||
{busy === "move" ? "Moving… (don't close this page)" : "Move sign-in to Accounts"}
|
||||
</button>
|
||||
<p className="text-xs text-gray-500">Pick a quiet time. It takes about a minute; people already signed in stay signed in. You can undo it for 14 days.</p>
|
||||
|
||||
@@ -72554,6 +72554,29 @@
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"messaging": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"whatsappTwoFactor": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"whatsappTwoFactor"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"description": "3.1.0: what Accounts can send; the move needs email"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -72565,7 +72588,8 @@
|
||||
"skipped",
|
||||
"admins",
|
||||
"noticeConflict",
|
||||
"withTwoFactor"
|
||||
"withTwoFactor",
|
||||
"messaging"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -72870,6 +72894,787 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/sign-in/messaging": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Email and WhatsApp: this site's, and what Accounts can send",
|
||||
"description": "**Who:** Admins only.",
|
||||
"operationId": "getSettingsSign-inMessaging",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"events": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string"
|
||||
},
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"secure": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"user": {
|
||||
"type": "string"
|
||||
},
|
||||
"from": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasPass": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"host",
|
||||
"port",
|
||||
"secure",
|
||||
"user",
|
||||
"from",
|
||||
"hasPass"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"whatsapp": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"instanceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasToken": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"instanceId",
|
||||
"hasToken"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"description": "This site's own settings, to copy (never the password or token)"
|
||||
},
|
||||
"accounts": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ready": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"host": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"from": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ready",
|
||||
"host",
|
||||
"from"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ready": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"instanceId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ready",
|
||||
"instanceId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "What the church's Accounts can send (null: it can't be reached)"
|
||||
},
|
||||
"accountsError": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"events",
|
||||
"accounts",
|
||||
"accountsError"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Save email / WhatsApp settings in Accounts (after a test)",
|
||||
"description": "Accounts tests each part as /test does, and saves it only if its test worked.\n\n**Who:** Admins only.",
|
||||
"operationId": "postSettingsSign-inMessaging",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 253
|
||||
},
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 65535
|
||||
},
|
||||
"secure": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"user": {
|
||||
"type": "string",
|
||||
"maxLength": 254
|
||||
},
|
||||
"from": {
|
||||
"type": "string",
|
||||
"minLength": 3,
|
||||
"maxLength": 320
|
||||
},
|
||||
"pass": {
|
||||
"description": "Blank: this site's own password",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 500
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
|
||||
"description": "Where the test email goes"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"host",
|
||||
"port",
|
||||
"secure",
|
||||
"user",
|
||||
"from",
|
||||
"to"
|
||||
]
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"instanceId": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 200
|
||||
},
|
||||
"accessToken": {
|
||||
"description": "Blank: this site's own token",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 500
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"maxLength": 30,
|
||||
"description": "The phone the test message goes to"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"instanceId",
|
||||
"to"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"error": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"saved": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok",
|
||||
"error",
|
||||
"saved"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"whatsapp": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"error": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"saved": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok",
|
||||
"error",
|
||||
"saved"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ready": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"host": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"from": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ready",
|
||||
"host",
|
||||
"from"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ready": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"instanceId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ready",
|
||||
"instanceId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"status"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/sign-in/messaging/test": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Test email / WhatsApp settings through Accounts (nothing saved)",
|
||||
"description": "Accounts sends a test email to `email.to` and a WhatsApp message to `whatsapp.to` with the settings given. A blank password or token uses this site's own.\n\n**Who:** Admins only.",
|
||||
"operationId": "postSettingsSign-inMessagingTest",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 253
|
||||
},
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 65535
|
||||
},
|
||||
"secure": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"user": {
|
||||
"type": "string",
|
||||
"maxLength": 254
|
||||
},
|
||||
"from": {
|
||||
"type": "string",
|
||||
"minLength": 3,
|
||||
"maxLength": 320
|
||||
},
|
||||
"pass": {
|
||||
"description": "Blank: this site's own password",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 500
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
|
||||
"description": "Where the test email goes"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"host",
|
||||
"port",
|
||||
"secure",
|
||||
"user",
|
||||
"from",
|
||||
"to"
|
||||
]
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"instanceId": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 200
|
||||
},
|
||||
"accessToken": {
|
||||
"description": "Blank: this site's own token",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 500
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"maxLength": 30,
|
||||
"description": "The phone the test message goes to"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"instanceId",
|
||||
"to"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"error": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"saved": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok",
|
||||
"error",
|
||||
"saved"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"whatsapp": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"error": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"saved": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok",
|
||||
"error",
|
||||
"saved"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ready": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"host": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"from": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ready",
|
||||
"host",
|
||||
"from"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ready": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"instanceId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ready",
|
||||
"instanceId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"status"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/account/reset-two-factor": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
||||
+317
@@ -7606,6 +7606,54 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/settings/sign-in/messaging": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
/**
|
||||
* Email and WhatsApp: this site's, and what Accounts can send
|
||||
* @description **Who:** Admins only.
|
||||
*/
|
||||
get: operations["getSettingsSign-inMessaging"];
|
||||
put?: never;
|
||||
/**
|
||||
* Save email / WhatsApp settings in Accounts (after a test)
|
||||
* @description Accounts tests each part as /test does, and saves it only if its test worked.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postSettingsSign-inMessaging"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/settings/sign-in/messaging/test": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Test email / WhatsApp settings through Accounts (nothing saved)
|
||||
* @description Accounts sends a test email to `email.to` and a WhatsApp message to `whatsapp.to` with the settings given. A blank password or token uses this site's own.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postSettingsSign-inMessagingTest"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/users/{id}/account/reset-two-factor": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -39892,6 +39940,12 @@ export interface operations {
|
||||
eventsVersions: number[];
|
||||
} | null;
|
||||
withTwoFactor: number;
|
||||
/** @description 3.1.0: what Accounts can send; the move needs email */
|
||||
messaging: {
|
||||
email: boolean;
|
||||
whatsapp: boolean;
|
||||
whatsappTwoFactor: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -40044,6 +40098,269 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
"getSettingsSign-inMessaging": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/** @description This site's own settings, to copy (never the password or token) */
|
||||
events: {
|
||||
email: {
|
||||
host: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
user: string;
|
||||
from: string;
|
||||
hasPass: boolean;
|
||||
} | null;
|
||||
whatsapp: {
|
||||
instanceId: string;
|
||||
hasToken: boolean;
|
||||
} | null;
|
||||
};
|
||||
/** @description What the church's Accounts can send (null: it can't be reached) */
|
||||
accounts: {
|
||||
email: {
|
||||
ready: boolean;
|
||||
host: string | null;
|
||||
from: string | null;
|
||||
};
|
||||
whatsapp: {
|
||||
ready: boolean;
|
||||
instanceId: string | null;
|
||||
};
|
||||
} | null;
|
||||
accountsError: string | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postSettingsSign-inMessaging": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
email?: {
|
||||
host: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
user: string;
|
||||
from: string;
|
||||
/** @description Blank: this site's own password */
|
||||
pass?: string | null;
|
||||
/**
|
||||
* Format: email
|
||||
* @description Where the test email goes
|
||||
*/
|
||||
to: string;
|
||||
};
|
||||
whatsapp?: {
|
||||
instanceId: string;
|
||||
/** @description Blank: this site's own token */
|
||||
accessToken?: string | null;
|
||||
/** @description The phone the test message goes to */
|
||||
to: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
email: {
|
||||
ok: boolean;
|
||||
error: string | null;
|
||||
saved: boolean;
|
||||
} | null;
|
||||
whatsapp: {
|
||||
ok: boolean;
|
||||
error: string | null;
|
||||
saved: boolean;
|
||||
} | null;
|
||||
status: {
|
||||
email: {
|
||||
ready: boolean;
|
||||
host: string | null;
|
||||
from: string | null;
|
||||
};
|
||||
whatsapp: {
|
||||
ready: boolean;
|
||||
instanceId: string | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Validation failed (VALIDATION_FAILED) */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postSettingsSign-inMessagingTest": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
email?: {
|
||||
host: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
user: string;
|
||||
from: string;
|
||||
/** @description Blank: this site's own password */
|
||||
pass?: string | null;
|
||||
/**
|
||||
* Format: email
|
||||
* @description Where the test email goes
|
||||
*/
|
||||
to: string;
|
||||
};
|
||||
whatsapp?: {
|
||||
instanceId: string;
|
||||
/** @description Blank: this site's own token */
|
||||
accessToken?: string | null;
|
||||
/** @description The phone the test message goes to */
|
||||
to: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
email: {
|
||||
ok: boolean;
|
||||
error: string | null;
|
||||
saved: boolean;
|
||||
} | null;
|
||||
whatsapp: {
|
||||
ok: boolean;
|
||||
error: string | null;
|
||||
saved: boolean;
|
||||
} | null;
|
||||
status: {
|
||||
email: {
|
||||
ready: boolean;
|
||||
host: string | null;
|
||||
from: string | null;
|
||||
};
|
||||
whatsapp: {
|
||||
ready: boolean;
|
||||
instanceId: string | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Validation failed (VALIDATION_FAILED) */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postUsersIdAccountReset-two-factor": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
|
||||
Reference in New Issue
Block a user