Mail relay: contract 1.6.0, the token tied to its host, IWSN in the panel
- contracts/mail-relay refreshed from IWDL 83af8c6 (1.6.0) - an answer that is not the service's JSON is 'not confirmed' unless its status is 400 to 499 - a site with a token issued by hand does not enrol to heal: it stops and says what to ask Intecion for - a store made on another host (a database copied to staging) is not used: the copy enrols as itself, nothing is revoked - the panel calls the service IWSN (RELAY_SHORT_NAME); docs, logs and the doctor keep the full name Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
7d766b6d58
commit
0ee74ab2a4
@@ -82,11 +82,13 @@ export const MailRelayStatus = () => {
|
||||
const relay = state.relay
|
||||
const onRelay = state.transport === 'relay'
|
||||
const relayState = !relay ? '' : relay.disconnected ? text('mailRelayStateDisconnected')
|
||||
: !relay.connected ? (state.refusalText ?? text('mailRelayStateNotConnected'))
|
||||
// why the service does not take this site: a refused enrolment, or a hand-issued token that stopped working
|
||||
: state.refusalText ? state.refusalText
|
||||
: !relay.connected ? text('mailRelayStateNotConnected')
|
||||
: relay.state === 'pending' ? text('mailRelayStatePending')
|
||||
: relay.state === 'suspended' ? text('mailRelayStateSuspended')
|
||||
: text('mailRelayStateActive')
|
||||
const attention = Boolean(relay && onRelay && (relay.disconnected || relay.state === 'pending' || relay.state === 'suspended' || (!relay.connected && state.refusalText)))
|
||||
const attention = Boolean(relay && onRelay && (relay.disconnected || relay.state === 'pending' || relay.state === 'suspended' || state.refusalText))
|
||||
|
||||
return (
|
||||
<div data-mail-transport={state.transport} style={box}>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Condition, Field } from 'payload'
|
||||
|
||||
import { RELAY_SHORT_NAME as IWSN } from '../../../modules/email/relay/constants.js'
|
||||
import { buildIntegrationStatusBanner, buildIntegrationStatusField } from '../../../modules/integrations/status.js'
|
||||
|
||||
/**
|
||||
@@ -36,8 +37,8 @@ export const buildSmtpFields = ({ relay = true }: { relay?: boolean } = {}): Fie
|
||||
admin: {
|
||||
description: relay
|
||||
? {
|
||||
en: 'Automatic uses your SMTP server when it is filled in below, and the built-in mail service otherwise.',
|
||||
pl: 'Automatycznie: przez Twój serwer SMTP, jeśli jest uzupełniony poniżej, a w innym razie przez wbudowaną usługę pocztową.',
|
||||
en: `Automatic uses your SMTP server when it is filled in below, and ${IWSN} otherwise.`,
|
||||
pl: `Automatycznie: przez Twój serwer SMTP, jeśli jest uzupełniony poniżej, a w innym razie przez ${IWSN}.`,
|
||||
}
|
||||
: {
|
||||
en: 'Microsoft Graph works only when your administrator has set it up on the server.',
|
||||
@@ -108,8 +109,8 @@ export const buildSmtpFields = ({ relay = true }: { relay?: boolean } = {}): Fie
|
||||
...(relay
|
||||
? {
|
||||
description: {
|
||||
en: 'Optional: fill in only to send through your own mail server instead of the built-in mail service.',
|
||||
pl: 'Opcjonalne: uzupełnij tylko, aby wysyłać przez własny serwer zamiast wbudowanej usługi pocztowej.',
|
||||
en: `Optional: fill in only to send through your own mail server instead of ${IWSN}.`,
|
||||
pl: `Opcjonalne: uzupełnij tylko, aby wysyłać przez własny serwer zamiast ${IWSN}.`,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
||||
@@ -243,6 +243,7 @@ export {
|
||||
RELAY_PRODUCT,
|
||||
RELAY_SENDER_ADDRESS,
|
||||
RELAY_SERVICE_NAME,
|
||||
RELAY_SHORT_NAME,
|
||||
RELAY_STATUS_CODES,
|
||||
relayAdapter,
|
||||
relayAttachmentLimit,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { RELAY_SHORT_NAME as IWSN } from '../../email/relay/constants.js'
|
||||
import { defineTexts } from '../define.js'
|
||||
|
||||
/** Admin component texts — integrations. Placeholders use Payload's {{name}} syntax. */
|
||||
@@ -12,37 +13,39 @@ export const integrationsTexts = defineTexts({
|
||||
// Intecion mail service: the state block on the e-mail tab (MailRelayStatus) and its routes
|
||||
mailRelayCheck: 'Check now',
|
||||
mailRelayConnect: 'Connect again',
|
||||
mailRelayConnected: 'The site is connected to the built-in mail service.',
|
||||
mailRelayConnected: `The site is connected to ${IWSN}.`,
|
||||
mailRelayConnectFailed: 'The site could not be connected. {{reason}}',
|
||||
mailRelayDisconnect: 'Disconnect',
|
||||
mailRelayDisconnectConfirm: 'Disconnect the site from the built-in mail service? E-mails will not be sent until you connect again or fill in an SMTP server.',
|
||||
mailRelayDisconnected: 'The site is disconnected from the built-in mail service.',
|
||||
mailRelayDisconnectConfirm: `Disconnect the site from ${IWSN}? E-mails will not be sent until you connect again or fill in an SMTP server.`,
|
||||
mailRelayDisconnected: `The site is disconnected from ${IWSN}.`,
|
||||
mailRelayForbidden: 'Only an administrator can do this.',
|
||||
mailRelayHeading: 'How e-mails are sent',
|
||||
mailRelayLoadFailed: 'The state could not be read. Try again.',
|
||||
mailRelayLoggedOut: 'Your session has ended. Log in again.',
|
||||
mailRelayNameReplaced: 'The sender name "{{asked}}" was not accepted, so e-mails leave as "{{used}}". Choose another name below.',
|
||||
mailRelayNameReplaced: `${IWSN} did not accept the sender name "{{asked}}", so e-mails leave as "{{used}}". Choose another name below.`,
|
||||
mailRelayNoReplyAddress: 'No reply address is set. Fill in "Sender address" below, or replies to these e-mails will be lost.',
|
||||
mailRelayOff: 'The built-in mail service is switched off for this site.',
|
||||
mailRelayOff: `${IWSN} is switched off for this site.`,
|
||||
mailRelayQuota: 'Left this hour: {{hour}}. Left today: {{day}}.',
|
||||
mailRelayRefusedCallback: 'The mail service could not reach this site at {{url}}. Reason: {{reason}}. Ask your administrator.',
|
||||
mailRelayRefusedClosed: 'The mail service does not take new sites at the moment. Ask your administrator.',
|
||||
mailRelayRefusedHost: 'This site has no public address yet ({{host}}). The mail service works once the site runs on its domain.',
|
||||
mailRelayRefusedAddress: `${IWSN} does not know the server this site now runs on. Ask your administrator to have its address added.`,
|
||||
mailRelayRefusedCallback: `${IWSN} could not reach this site at {{url}}. Reason: {{reason}}. Ask your administrator.`,
|
||||
mailRelayRefusedClosed: `${IWSN} does not take new sites at the moment. Ask your administrator.`,
|
||||
mailRelayRefusedHost: `This site has no public address yet ({{host}}). ${IWSN} works once the site runs on its domain.`,
|
||||
mailRelayRefusedNoHost: 'The site does not know its own address. Ask your administrator.',
|
||||
mailRelayRefusedOther: 'The mail service answered: {{message}}',
|
||||
mailRelayRefusedOther: `${IWSN} answered: {{message}}`,
|
||||
mailRelayRefusedToken: `The access key of this site is no longer valid. Ask your administrator for a new one.`,
|
||||
mailRelayRepliesTo: 'Replies go to {{address}}.',
|
||||
mailRelayStateActive: 'Connected to the built-in mail service.',
|
||||
mailRelayStateActive: `Connected to ${IWSN}.`,
|
||||
mailRelayStateDisconnected: 'Disconnected. E-mails are not sent until you connect again or fill in an SMTP server.',
|
||||
mailRelayStateNotConnected: 'Not connected yet. The site connects by itself when it sends its first e-mail.',
|
||||
mailRelayStatePending: 'The site is waiting for approval, so e-mails are not sent yet. Ask your administrator.',
|
||||
mailRelayStateSuspended: 'E-mail sending was stopped for this site. Ask your administrator.',
|
||||
mailRelayToken: 'Enter an access key',
|
||||
mailRelayTokenHint: 'Only when your administrator gave you a key for this site. It is stored and never shown again.',
|
||||
mailRelayTokenInvalid: 'This is not an access key of the mail service.',
|
||||
mailRelayTokenInvalid: `This is not an access key of ${IWSN}.`,
|
||||
mailRelayTokenSave: 'Save the key',
|
||||
mailRelayTransportGraph: 'E-mails go through Microsoft Graph. This method will be removed in version 2.0.',
|
||||
mailRelayTransportNone: 'No sending method is set up. E-mails are not sent.',
|
||||
mailRelayTransportRelay: 'E-mails go through the built-in mail service, from {{address}}.',
|
||||
mailRelayTransportRelay: `E-mails go through ${IWSN}, from {{address}}.`,
|
||||
mailRelayTransportSmtp: 'E-mails go through your SMTP server.',
|
||||
mailRelayWorking: 'Working…',
|
||||
|
||||
@@ -74,17 +77,17 @@ export const integrationsTexts = defineTexts({
|
||||
'Microsoft Graph cannot send files of 3 MB and more here, so larger form files are limited or go over SMTP. Ask your administrator.',
|
||||
statusEmailGraphUnavailable:
|
||||
'Microsoft Graph is selected but not set up on the server, so e-mails go over SMTP. Ask your administrator.',
|
||||
statusEmailRelayAttachmentRefused: 'The built-in mail service does not carry this type of file. The e-mail was not sent.',
|
||||
statusEmailRelayDisconnected: 'The site is disconnected from the built-in mail service, so e-mails are not sent. Connect again, or fill in an SMTP server.',
|
||||
statusEmailRelayError: 'The built-in mail service refused the e-mail. Tell your administrator.',
|
||||
statusEmailRelayNotConfirmed: 'The built-in mail service did not confirm the last e-mail. It may have been sent.',
|
||||
statusEmailRelayAttachmentRefused: `${IWSN} does not carry this type of file. The e-mail was not sent.`,
|
||||
statusEmailRelayDisconnected: `The site is disconnected from ${IWSN}, so e-mails are not sent. Connect again, or fill in an SMTP server.`,
|
||||
statusEmailRelayError: `${IWSN} refused the e-mail. Tell your administrator.`,
|
||||
statusEmailRelayNotConfirmed: `${IWSN} did not confirm the last e-mail. It may have been sent.`,
|
||||
statusEmailRelayPending: 'The site is waiting for approval, so e-mails are not sent yet. Ask your administrator.',
|
||||
statusEmailRelayQuota: 'The site reached a sending limit of the built-in mail service. The e-mail was not sent.',
|
||||
statusEmailRelayRecipientSuppressed: 'The mail service refuses one of the recipients, because earlier e-mails to that address came back. Nothing was sent.',
|
||||
statusEmailRelayRefused: 'The built-in mail service did not connect this site. See the state above, or fill in an SMTP server.',
|
||||
statusEmailRelayQuota: `The site reached a sending limit of ${IWSN}. The e-mail was not sent.`,
|
||||
statusEmailRelayRecipientSuppressed: `${IWSN} refuses one of the recipients, because earlier e-mails to that address came back. Nothing was sent.`,
|
||||
statusEmailRelayRefused: `${IWSN} did not connect this site. See the state above, or fill in an SMTP server.`,
|
||||
statusEmailRelaySuspended: 'E-mail sending was stopped for this site. Ask your administrator.',
|
||||
statusEmailRelayTooLarge: 'The e-mail or its files are larger than the built-in mail service carries. The e-mail was not sent.',
|
||||
statusEmailRelayUnreachable: 'The built-in mail service could not be reached or failed. The e-mail was probably not sent.',
|
||||
statusEmailRelayTooLarge: `The e-mail or its files are larger than ${IWSN} carries. The e-mail was not sent.`,
|
||||
statusEmailRelayUnreachable: `${IWSN} could not be reached or failed. The e-mail was probably not sent.`,
|
||||
statusTurnstileBadResponse: 'Cloudflare sent an unexpected response.',
|
||||
statusTurnstileInternalError: 'Cloudflare reported an internal error. It usually passes on its own.',
|
||||
statusTurnstileInvalidSecret: 'Cloudflare rejected the secret key. Both keys must come from the same widget.',
|
||||
@@ -104,12 +107,12 @@ export const integrationsTexts = defineTexts({
|
||||
testEmailLoggedOut: 'Your session has ended. Log in again.',
|
||||
testEmailNoConnection: 'Could not reach the server. Check your connection and try again.',
|
||||
testEmailNotConfigured: 'Fill in the server, user name and password, then save.',
|
||||
testEmailNotConfirmed: 'The mail service did not confirm the test e-mail. It may have been sent; check the mailbox before trying again.',
|
||||
testEmailNotConfirmed: `${IWSN} did not confirm the test e-mail. It may have been sent; check the mailbox before trying again.`,
|
||||
testEmailRecipient: 'Recipient address',
|
||||
testEmailSend: 'Send test e-mail',
|
||||
testEmailSending: 'Sending…',
|
||||
testEmailSent: 'Test e-mail sent to {{to}}.',
|
||||
testEmailSentRelay: 'Test e-mail sent to {{to}} through the built-in mail service, as "{{name}}".',
|
||||
testEmailSentRelay: `Test e-mail sent to {{to}} through ${IWSN}, as "{{name}}".`,
|
||||
testEmailSentSmtp: 'Test e-mail sent to {{to}} through your SMTP server.',
|
||||
testEmailSubject: 'Test e-mail from {{site}}',
|
||||
testEmailSubjectGeneric: 'Test e-mail from your website',
|
||||
@@ -123,37 +126,39 @@ export const integrationsTexts = defineTexts({
|
||||
|
||||
mailRelayCheck: 'Sprawdź teraz',
|
||||
mailRelayConnect: 'Połącz ponownie',
|
||||
mailRelayConnected: 'Witryna jest połączona z wbudowaną usługą pocztową.',
|
||||
mailRelayConnected: `Witryna jest połączona z ${IWSN}.`,
|
||||
mailRelayConnectFailed: 'Nie udało się połączyć witryny. {{reason}}',
|
||||
mailRelayDisconnect: 'Rozłącz',
|
||||
mailRelayDisconnectConfirm: 'Rozłączyć witrynę z wbudowaną usługą pocztową? E-maile nie będą wysyłane, dopóki nie połączysz jej ponownie albo nie uzupełnisz serwera SMTP.',
|
||||
mailRelayDisconnected: 'Witryna jest rozłączona z wbudowaną usługą pocztową.',
|
||||
mailRelayDisconnectConfirm: `Rozłączyć witrynę z ${IWSN}? E-maile nie będą wysyłane, dopóki nie połączysz jej ponownie albo nie uzupełnisz serwera SMTP.`,
|
||||
mailRelayDisconnected: `Witryna jest rozłączona z ${IWSN}.`,
|
||||
mailRelayForbidden: 'Tylko administrator może to zrobić.',
|
||||
mailRelayHeading: 'Jak wysyłane są e-maile',
|
||||
mailRelayLoadFailed: 'Nie udało się odczytać stanu. Spróbuj ponownie.',
|
||||
mailRelayLoggedOut: 'Sesja wygasła. Zaloguj się ponownie.',
|
||||
mailRelayNameReplaced: 'Nazwa nadawcy „{{asked}}” nie została przyjęta, więc e-maile wychodzą jako „{{used}}”. Wybierz inną nazwę poniżej.',
|
||||
mailRelayNameReplaced: `${IWSN} nie przyjął nazwy nadawcy „{{asked}}”, więc e-maile wychodzą jako „{{used}}”. Wybierz inną nazwę poniżej.`,
|
||||
mailRelayNoReplyAddress: 'Nie ustawiono adresu do odpowiedzi. Uzupełnij „Adres nadawcy” poniżej, inaczej odpowiedzi na te e-maile przepadną.',
|
||||
mailRelayOff: 'Wbudowana usługa pocztowa jest wyłączona dla tej witryny.',
|
||||
mailRelayOff: `${IWSN} jest wyłączony dla tej witryny.`,
|
||||
mailRelayQuota: 'Pozostało w tej godzinie: {{hour}}. Pozostało dziś: {{day}}.',
|
||||
mailRelayRefusedCallback: 'Usługa pocztowa nie mogła połączyć się z witryną pod adresem {{url}}. Powód: {{reason}}. Zapytaj administratora.',
|
||||
mailRelayRefusedClosed: 'Usługa pocztowa nie przyjmuje teraz nowych witryn. Zapytaj administratora.',
|
||||
mailRelayRefusedHost: 'Witryna nie ma jeszcze publicznego adresu ({{host}}). Usługa pocztowa zadziała, gdy witryna będzie dostępna pod swoją domeną.',
|
||||
mailRelayRefusedAddress: `${IWSN} nie zna serwera, na którym teraz działa witryna. Poproś administratora o dodanie jego adresu.`,
|
||||
mailRelayRefusedCallback: `${IWSN} nie mógł połączyć się z witryną pod adresem {{url}}. Powód: {{reason}}. Zapytaj administratora.`,
|
||||
mailRelayRefusedClosed: `${IWSN} nie przyjmuje teraz nowych witryn. Zapytaj administratora.`,
|
||||
mailRelayRefusedHost: `Witryna nie ma jeszcze publicznego adresu ({{host}}). ${IWSN} zadziała, gdy witryna będzie dostępna pod swoją domeną.`,
|
||||
mailRelayRefusedNoHost: 'Witryna nie zna własnego adresu. Zapytaj administratora.',
|
||||
mailRelayRefusedOther: 'Usługa pocztowa odpowiedziała: {{message}}',
|
||||
mailRelayRefusedOther: `${IWSN} odpowiedział: {{message}}`,
|
||||
mailRelayRefusedToken: `Klucz dostępu tej witryny stracił ważność. Poproś administratora o nowy.`,
|
||||
mailRelayRepliesTo: 'Odpowiedzi trafiają na adres {{address}}.',
|
||||
mailRelayStateActive: 'Połączono z wbudowaną usługą pocztową.',
|
||||
mailRelayStateActive: `Połączono z ${IWSN}.`,
|
||||
mailRelayStateDisconnected: 'Rozłączono. E-maile nie są wysyłane, dopóki nie połączysz witryny ponownie albo nie uzupełnisz serwera SMTP.',
|
||||
mailRelayStateNotConnected: 'Jeszcze nie połączono. Witryna połączy się sama, gdy wyśle pierwszy e-mail.',
|
||||
mailRelayStatePending: 'Witryna czeka na zatwierdzenie, więc e-maile nie są jeszcze wysyłane. Zapytaj administratora.',
|
||||
mailRelayStateSuspended: 'Wysyłka e-maili z tej witryny została wstrzymana. Zapytaj administratora.',
|
||||
mailRelayToken: 'Wpisz klucz dostępu',
|
||||
mailRelayTokenHint: 'Tylko jeśli administrator przekazał Ci klucz dla tej witryny. Klucz zostanie zapisany i nie będzie więcej pokazywany.',
|
||||
mailRelayTokenInvalid: 'To nie jest klucz dostępu usługi pocztowej.',
|
||||
mailRelayTokenInvalid: `To nie jest klucz dostępu ${IWSN}.`,
|
||||
mailRelayTokenSave: 'Zapisz klucz',
|
||||
mailRelayTransportGraph: 'E-maile idą przez Microsoft Graph. Ten sposób zostanie usunięty w wersji 2.0.',
|
||||
mailRelayTransportNone: 'Nie ustawiono żadnego sposobu wysyłki. E-maile nie są wysyłane.',
|
||||
mailRelayTransportRelay: 'E-maile idą przez wbudowaną usługę pocztową, z adresu {{address}}.',
|
||||
mailRelayTransportRelay: `E-maile idą przez ${IWSN}, z adresu {{address}}.`,
|
||||
mailRelayTransportSmtp: 'E-maile idą przez Twój serwer SMTP.',
|
||||
mailRelayWorking: 'Trwa…',
|
||||
|
||||
@@ -182,17 +187,17 @@ export const integrationsTexts = defineTexts({
|
||||
'Microsoft Graph nie może tu wysyłać plików od 3 MB, więc większe pliki z formularzy są ograniczone lub idą przez SMTP. Zapytaj administratora.',
|
||||
statusEmailGraphUnavailable:
|
||||
'Wybrano Microsoft Graph, ale nie jest on skonfigurowany na serwerze, więc e-maile idą przez SMTP. Zapytaj administratora.',
|
||||
statusEmailRelayAttachmentRefused: 'Wbudowana usługa pocztowa nie przesyła plików tego typu. E-mail nie został wysłany.',
|
||||
statusEmailRelayDisconnected: 'Witryna jest rozłączona z wbudowaną usługą pocztową, więc e-maile nie są wysyłane. Połącz ją ponownie albo uzupełnij serwer SMTP.',
|
||||
statusEmailRelayError: 'Wbudowana usługa pocztowa odrzuciła e-mail. Powiadom administratora.',
|
||||
statusEmailRelayNotConfirmed: 'Wbudowana usługa pocztowa nie potwierdziła ostatniego e-maila. Mógł zostać wysłany.',
|
||||
statusEmailRelayAttachmentRefused: `${IWSN} nie przesyła plików tego typu. E-mail nie został wysłany.`,
|
||||
statusEmailRelayDisconnected: `Witryna jest rozłączona z ${IWSN}, więc e-maile nie są wysyłane. Połącz ją ponownie albo uzupełnij serwer SMTP.`,
|
||||
statusEmailRelayError: `${IWSN} odrzucił e-mail. Powiadom administratora.`,
|
||||
statusEmailRelayNotConfirmed: `${IWSN} nie potwierdził ostatniego e-maila. Mógł zostać wysłany.`,
|
||||
statusEmailRelayPending: 'Witryna czeka na zatwierdzenie, więc e-maile nie są jeszcze wysyłane. Zapytaj administratora.',
|
||||
statusEmailRelayQuota: 'Witryna osiągnęła limit wysyłki we wbudowanej usłudze pocztowej. E-mail nie został wysłany.',
|
||||
statusEmailRelayRecipientSuppressed: 'Usługa pocztowa odrzuca jednego z odbiorców, bo wcześniejsze e-maile na ten adres wróciły. Nic nie zostało wysłane.',
|
||||
statusEmailRelayRefused: 'Wbudowana usługa pocztowa nie połączyła tej witryny. Zobacz stan powyżej albo uzupełnij serwer SMTP.',
|
||||
statusEmailRelayQuota: `Witryna osiągnęła limit wysyłki w ${IWSN}. E-mail nie został wysłany.`,
|
||||
statusEmailRelayRecipientSuppressed: `${IWSN} odrzuca jednego z odbiorców, bo wcześniejsze e-maile na ten adres wróciły. Nic nie zostało wysłane.`,
|
||||
statusEmailRelayRefused: `${IWSN} nie połączył tej witryny. Zobacz stan powyżej albo uzupełnij serwer SMTP.`,
|
||||
statusEmailRelaySuspended: 'Wysyłka e-maili z tej witryny została wstrzymana. Zapytaj administratora.',
|
||||
statusEmailRelayTooLarge: 'E-mail lub jego pliki są większe, niż przesyła wbudowana usługa pocztowa. E-mail nie został wysłany.',
|
||||
statusEmailRelayUnreachable: 'Wbudowana usługa pocztowa była nieosiągalna albo zawiodła. E-mail prawdopodobnie nie został wysłany.',
|
||||
statusEmailRelayTooLarge: `E-mail lub jego pliki są większe, niż przesyła ${IWSN}. E-mail nie został wysłany.`,
|
||||
statusEmailRelayUnreachable: `${IWSN} był nieosiągalny albo zawiódł. E-mail prawdopodobnie nie został wysłany.`,
|
||||
statusTurnstileBadResponse: 'Cloudflare zwrócił nieoczekiwaną odpowiedź.',
|
||||
statusTurnstileInternalError: 'Cloudflare zgłosił błąd wewnętrzny. Zwykle ustępuje samoczynnie.',
|
||||
statusTurnstileInvalidSecret: 'Cloudflare odrzucił klucz tajny. Oba klucze muszą pochodzić z tego samego widżetu.',
|
||||
@@ -211,12 +216,12 @@ export const integrationsTexts = defineTexts({
|
||||
testEmailLoggedOut: 'Sesja wygasła. Zaloguj się ponownie.',
|
||||
testEmailNoConnection: 'Brak połączenia z serwerem. Sprawdź połączenie i spróbuj ponownie.',
|
||||
testEmailNotConfigured: 'Uzupełnij serwer, nazwę użytkownika i hasło, a następnie zapisz.',
|
||||
testEmailNotConfirmed: 'Usługa pocztowa nie potwierdziła testowego e-maila. Mógł zostać wysłany; sprawdź skrzynkę, zanim spróbujesz ponownie.',
|
||||
testEmailNotConfirmed: `${IWSN} nie potwierdził testowego e-maila. Mógł zostać wysłany; sprawdź skrzynkę, zanim spróbujesz ponownie.`,
|
||||
testEmailRecipient: 'Adres odbiorcy',
|
||||
testEmailSend: 'Wyślij testowy e-mail',
|
||||
testEmailSending: 'Wysyłanie…',
|
||||
testEmailSent: 'Testowy e-mail wysłano na adres {{to}}.',
|
||||
testEmailSentRelay: 'Testowy e-mail wysłano na adres {{to}} przez wbudowaną usługę pocztową, jako „{{name}}”.',
|
||||
testEmailSentRelay: `Testowy e-mail wysłano na adres {{to}} przez ${IWSN}, jako „{{name}}”.`,
|
||||
testEmailSentSmtp: 'Testowy e-mail wysłano na adres {{to}} przez Twój serwer SMTP.',
|
||||
testEmailSubject: 'Testowy e-mail z witryny {{site}}',
|
||||
testEmailSubjectGeneric: 'Testowy e-mail z witryny',
|
||||
|
||||
@@ -7,8 +7,7 @@ import { getSiteIntegrations } from '../../payload/index.js'
|
||||
import { RELAY_DEFAULTS } from './constants.js'
|
||||
import { resolveRelayOptions } from './options.js'
|
||||
import { type RelaySendResult, sendThroughRelay } from './send.js'
|
||||
import { refreshRelayStatus } from './session.js'
|
||||
import { readRelayStore } from './store.js'
|
||||
import { readSiteStore, refreshRelayStatus } from './session.js'
|
||||
|
||||
/** The address mail leaves from until the service has been asked (`/v1/status` reports the real one). */
|
||||
export const RELAY_SENDER_ADDRESS = '[email protected]'
|
||||
@@ -60,7 +59,7 @@ export async function sendRelayWithPanel(payload: BasePayload, options: Resolved
|
||||
* the site has enrolled: the plugin has no constant of its own for it.
|
||||
*/
|
||||
export async function relayAttachmentLimit(payload: BasePayload, options: ResolvedRelayOptions): Promise<null | number> {
|
||||
let stored = await readRelayStore(payload)
|
||||
let stored = await readSiteStore(payload, options)
|
||||
const stale = !stored.service || Date.now() - Date.parse(stored.service.fetchedAt) > RELAY_DEFAULTS.statusTtlMs
|
||||
if (stale && (stored.token || options.token !== undefined) && !stored.disconnected) {
|
||||
stored = (await refreshRelayStatus(payload, options)).stored
|
||||
|
||||
@@ -7,7 +7,10 @@ export type RelayRefusal = {
|
||||
field?: string
|
||||
limit?: string
|
||||
message: string
|
||||
/** No usable answer came at all (time-out, connection lost): the request may have been carried out. */
|
||||
/**
|
||||
* No answer of the service came (time-out, connection lost, or an answer that is not its JSON with a status
|
||||
* outside 400–499): the request may have been carried out.
|
||||
*/
|
||||
noAnswer: boolean
|
||||
ok: false
|
||||
reason?: string
|
||||
@@ -37,8 +40,9 @@ const firstLine = (text: string) => text.split('\n')[0].slice(0, 300)
|
||||
|
||||
/**
|
||||
* One request to the service. Never throws. An answer that is not the contract's JSON — an error page
|
||||
* of the network in front, an empty or cut-off body, a redirect — is `503 unavailable`, retryable; a
|
||||
* request that got no answer at all is the same with `noAnswer: true`.
|
||||
* of the network in front, an empty or cut-off body, a redirect — is `unavailable`, retryable, and
|
||||
* counts as no answer (`noAnswer: true`) unless its status is 400 to 499; a request that got no answer
|
||||
* at all is the same with `noAnswer: true`.
|
||||
*/
|
||||
export async function relayRequest<T = Record<string, unknown>>(call: RelayCall): Promise<RelayAnswer<T>> {
|
||||
const controller = new AbortController()
|
||||
@@ -83,7 +87,10 @@ export async function relayRequest<T = Record<string, unknown>>(call: RelayCall)
|
||||
...(typeof body.reason === 'string' ? { reason: body.reason } : {}),
|
||||
}
|
||||
}
|
||||
return { code: 'unavailable', message: `The mail service answered ${status} without a usable body.`, noAnswer: false, ok: false, retryable: true, status }
|
||||
// Not the service's own JSON (an error page of the network in front, an empty or cut-off body). It may be
|
||||
// retried; what it says about the message depends on the status alone (contract §1): 400 to 499 — turned
|
||||
// away before the service handled it; anything else, 200 included — the service may have handled it.
|
||||
return { code: 'unavailable', message: `The mail service answered ${status} without a usable body.`, noAnswer: status < 400 || status > 499, ok: false, retryable: true, status }
|
||||
} catch (err) {
|
||||
const aborted = controller.signal.aborted
|
||||
return {
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
/** Base address: host and path together, joined with a path as text. Override: `mail: { relay: { url } }`. */
|
||||
export const RELAY_BASE_URL = 'https://webservices.intecion.net/mail'
|
||||
/** The version of the copied contract this client speaks (`contracts/mail-relay/VERSION`). */
|
||||
export const RELAY_CONTRACT_VERSION = '1.5.0'
|
||||
export const RELAY_CONTRACT_VERSION = '1.6.0'
|
||||
/** The `product` value of this plugin. */
|
||||
export const RELAY_PRODUCT = 'iapl'
|
||||
/** The service's name, for texts. */
|
||||
/** The service's name, for docs, logs and the doctor. */
|
||||
export const RELAY_SERVICE_NAME = 'Intecion Notifications Webservice'
|
||||
/** Its short name: what the admin panel calls it, in every language. The one place it is written. */
|
||||
export const RELAY_SHORT_NAME = 'IWSN'
|
||||
/** Where the service calls a site of this product back, under Payload's API route. Fixed by the contract. */
|
||||
export const RELAY_CONFIRM_PATH = '/iapl/mail-relay/confirm'
|
||||
/** Admin-only routes of the panel's status block. */
|
||||
|
||||
@@ -16,6 +16,7 @@ export {
|
||||
RELAY_KV_KEY,
|
||||
RELAY_PRODUCT,
|
||||
RELAY_SERVICE_NAME,
|
||||
RELAY_SHORT_NAME,
|
||||
RELAY_STATUS_CODES,
|
||||
relayStatusFor,
|
||||
} from './constants.js'
|
||||
|
||||
@@ -9,7 +9,7 @@ import { getSiteIntegrations } from '../../payload/index.js'
|
||||
import { graphAvailable, type MailTransport, resolveMailTransport } from '../mailAdapter.js'
|
||||
import { RELAY_SENDER_ADDRESS } from './adapter.js'
|
||||
import { RELAY_CONFIRM_PATH, RELAY_CONNECT_PATH, RELAY_DISCONNECT_PATH, RELAY_STATUS_PATH } from './constants.js'
|
||||
import { isPublicHost, resolveRelayOptions } from './options.js'
|
||||
import { isPublicHost, relayHost, resolveRelayOptions } from './options.js'
|
||||
import { disconnectRelay, enrolRelay, type EnrolResult, getRelayStatus, LOCAL_CODES, type RelayStatus, setRelayToken } from './session.js'
|
||||
|
||||
type Settings = {
|
||||
@@ -73,8 +73,13 @@ export function enrolRefusalText(i18n: I18n, refusal: { code: string; message?:
|
||||
return serverText(i18n, 'mailRelayRefusedClosed')
|
||||
case 'host-not-allowed':
|
||||
return serverText(i18n, 'mailRelayRefusedHost', { host: state.relay?.host ?? '' })
|
||||
// a token issued by hand that stopped working: the site cannot heal by itself
|
||||
case 'invalid-token':
|
||||
return serverText(i18n, 'mailRelayRefusedToken')
|
||||
case LOCAL_CODES.noHost:
|
||||
return serverText(i18n, 'mailRelayRefusedNoHost')
|
||||
case 'reverify':
|
||||
return serverText(i18n, 'mailRelayRefusedAddress')
|
||||
case 'site-suspended':
|
||||
return serverText(i18n, 'mailRelayStateSuspended')
|
||||
default:
|
||||
@@ -121,7 +126,7 @@ export function relayPanelEndpoints(own?: false | RelayOptions): Endpoint[] {
|
||||
}
|
||||
if (typeof body.token === 'string' && body.token.trim()) {
|
||||
try {
|
||||
await setRelayToken(req.payload, body.token.trim())
|
||||
await setRelayToken(req.payload, body.token.trim(), { host: relayHost(req.payload, options) || undefined })
|
||||
} catch {
|
||||
return json({ error: serverText(i18n, 'mailRelayTokenInvalid'), ok: false }, 400)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { type RelayAnswer, type RelayRefusal, relayRequest } from './client.js'
|
||||
import { RELAY_DEFAULTS, type RelayStatusCode, relayStatusFor } from './constants.js'
|
||||
import { currentMailKind, type MailKind, mailKindOf, takeExpectedMail } from './kinds.js'
|
||||
import { bareAddresses, buildRelayMessage, type RelaySendRequest } from './message.js'
|
||||
import { LOCAL_CODES, refreshRelayStatus, rotateRelayToken, type TokenUse, withRelayToken } from './session.js'
|
||||
import { LOCAL_CODES, readSiteStore, refreshRelayStatus, rotateRelayToken, type TokenUse, withRelayToken } from './session.js'
|
||||
import { readRelayStore, sha256Hex, updateRelayStore } from './store.js'
|
||||
|
||||
export type RelaySendResult =
|
||||
@@ -144,7 +144,7 @@ export async function sendThroughRelay(payload: BasePayload, options: ResolvedRe
|
||||
}
|
||||
}
|
||||
|
||||
const stored = await readRelayStore(payload)
|
||||
const stored = await readSiteStore(payload, options)
|
||||
const limits = stored.service && Date.now() - Date.parse(stored.service.fetchedAt) < RELAY_DEFAULTS.statusTtlMs ? stored.service.limits : undefined
|
||||
if (limits) {
|
||||
// What the service said within the last hour: no need to upload 10 MB to hear it again.
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
clearRelayStore,
|
||||
dropRelayCandidate,
|
||||
holdNonce,
|
||||
readOwnRelayStore,
|
||||
readRelayCandidate,
|
||||
readRelayStore,
|
||||
type RelaySiteState,
|
||||
@@ -21,6 +22,9 @@ import {
|
||||
updateRelayStore,
|
||||
} from './store.js'
|
||||
|
||||
/** The stored entry of this site — never one made on another host (store.ts). */
|
||||
export const readSiteStore = (payload: BasePayload, options: Pick<ResolvedRelayOptions, 'host'>) => readOwnRelayStore(payload, relayHost(payload, options))
|
||||
|
||||
const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))
|
||||
const refusal = (code: string, message: string, extra: Partial<RelayRefusal> = {}): RelayRefusal => ({ code, message, noAnswer: false, ok: false, retryable: false, status: 0, ...extra })
|
||||
|
||||
@@ -65,7 +69,7 @@ export function enrolRelay(payload: BasePayload, options: ResolvedRelayOptions,
|
||||
}
|
||||
|
||||
async function enrolOnce(payload: BasePayload, options: ResolvedRelayOptions, force: boolean): Promise<EnrolResult> {
|
||||
const stored = await readRelayStore(payload)
|
||||
const stored = await readSiteStore(payload, options)
|
||||
if (stored.disconnected && !force) {return enrolFailure(refusal(LOCAL_CODES.disconnected, 'The site was disconnected from the mail service in the panel.'))}
|
||||
if (!force && stored.refusal && Date.parse(stored.refusal.until) > Date.now()) {
|
||||
return enrolFailure(refusal(stored.refusal.code, stored.refusal.message ?? stored.refusal.code, { reason: stored.refusal.reason }))
|
||||
@@ -104,6 +108,7 @@ async function enrolOnce(payload: BasePayload, options: ResolvedRelayOptions, fo
|
||||
disconnected: false,
|
||||
enrolledAt: new Date().toISOString(),
|
||||
host,
|
||||
manual: false,
|
||||
refusal: null,
|
||||
source: 'enrolment',
|
||||
state,
|
||||
@@ -134,6 +139,21 @@ async function enrolOnce(payload: BasePayload, options: ResolvedRelayOptions, fo
|
||||
return enrolFailure(failed)
|
||||
}
|
||||
|
||||
const HAND_ISSUED = {
|
||||
'invalid-token': 'The token issued by hand for this site is no longer valid, and the site cannot enrol by itself: ask Intecion for a new token.',
|
||||
reverify: 'The site sends from a server address the mail service does not know, and with a token issued by hand it cannot enrol by itself: ask Intecion to add this server\'s address.',
|
||||
} as const
|
||||
|
||||
/**
|
||||
* A site with a token issued by hand cannot be called back, so "enrol again" is not open to it
|
||||
* (contract §2): it stops, says what to ask Intecion for, and keeps the token.
|
||||
*/
|
||||
async function handIssued(payload: BasePayload, code: keyof typeof HAND_ISSUED): Promise<RelayRefusal> {
|
||||
const now = new Date().toISOString()
|
||||
await updateRelayStore(payload, (current) => (current.refusal?.code === code ? current : { ...current, refusal: { at: now, code, message: HAND_ISSUED[code], until: now } }))
|
||||
return refusal(code, HAND_ISSUED[code])
|
||||
}
|
||||
|
||||
/** A token from the `token` option (a relay of one's own, a deployment secret), when the project set one. */
|
||||
async function optionToken(options: ResolvedRelayOptions): Promise<string | undefined> {
|
||||
if (options.token === undefined) {return undefined}
|
||||
@@ -164,7 +184,7 @@ export async function withRelayToken<T>(
|
||||
if (options.token !== undefined) {return refusal(LOCAL_CODES.noToken, 'mail.relay.token returned no token.')}
|
||||
|
||||
for (let round = 0; round < 4; round++) {
|
||||
const stored = await readRelayStore(payload)
|
||||
const stored = await readSiteStore(payload, options)
|
||||
if (stored.disconnected) {return refusal(LOCAL_CODES.disconnected, 'The site was disconnected from the mail service in the panel.')}
|
||||
const candidate = await readRelayCandidate(payload)
|
||||
const token = candidate?.token ?? stored.token
|
||||
@@ -196,16 +216,18 @@ export async function withRelayToken<T>(
|
||||
await dropRelayCandidate(payload)
|
||||
continue
|
||||
}
|
||||
if (stored.manual) {return handIssued(payload, 'invalid-token')}
|
||||
const failed = await enrolNow()
|
||||
if (failed) {return use.enrolment && !use.enrolment.ok ? failed : answer}
|
||||
continue
|
||||
}
|
||||
if (candidate) {
|
||||
// Seen accepted: this is the token now.
|
||||
await updateRelayStore(payload, (current) => ({ ...current, enrolledAt: candidate.at, host: relayHost(payload, options) || current.host, source: 'enrolment', state: candidate.state, token: candidate.token }))
|
||||
await updateRelayStore(payload, (current) => ({ ...current, enrolledAt: candidate.at, host: relayHost(payload, options) || current.host, manual: false, source: 'enrolment', state: candidate.state, token: candidate.token }))
|
||||
await dropRelayCandidate(payload)
|
||||
}
|
||||
if (!answer.ok && answer.code === 'reverify') {
|
||||
if (stored.manual) {return handIssued(payload, 'reverify')}
|
||||
const failed = await enrolNow()
|
||||
if (failed) {return use.enrolment && !use.enrolment.ok ? failed : answer}
|
||||
continue
|
||||
@@ -238,7 +260,7 @@ export async function refreshRelayStatus(payload: BasePayload, options: Resolved
|
||||
{},
|
||||
{ first: false },
|
||||
)
|
||||
if (!answer.ok) {return { error: answer, stored: await readRelayStore(payload) }}
|
||||
if (!answer.ok) {return { error: answer, stored: await readSiteStore(payload, options) }}
|
||||
const body = answer.body
|
||||
const stored = await updateRelayStore(payload, (current) => ({
|
||||
...current,
|
||||
@@ -263,7 +285,7 @@ export async function refreshRelayStatus(payload: BasePayload, options: Resolved
|
||||
* when the store already holds a newer token, else the site enrols again on its next send.
|
||||
*/
|
||||
export async function rotateRelayToken(payload: BasePayload, options: ResolvedRelayOptions, { force = false }: { force?: boolean } = {}): Promise<'failed' | 'not-due' | 'rotated'> {
|
||||
const stored = await readRelayStore(payload)
|
||||
const stored = await readSiteStore(payload, options)
|
||||
if (!stored.token || options.token !== undefined) {return 'not-due'}
|
||||
const due = stored.service?.rotateAfter ? Date.parse(stored.service.rotateAfter) : Number.NaN
|
||||
if (!force && !(due <= Date.now())) {return 'not-due'}
|
||||
@@ -293,7 +315,8 @@ export async function rotateRelayToken(payload: BasePayload, options: ResolvedRe
|
||||
|
||||
/** Gives the token up on the service (every token of the site stops working) and forgets it here. */
|
||||
export async function disconnectRelay(payload: BasePayload, options: ResolvedRelayOptions): Promise<void> {
|
||||
const stored = await readRelayStore(payload)
|
||||
// (a store copied from another host is dropped by this read: that site's token is never revoked from here)
|
||||
const stored = await readSiteStore(payload, options)
|
||||
if (stored.token && options.token === undefined) {
|
||||
await relayRequest({ fetchImpl: options.fetchImpl, method: 'POST', path: '/v1/revoke', token: stored.token, url: options.url })
|
||||
}
|
||||
@@ -312,6 +335,7 @@ export async function setRelayToken(payload: BasePayload, token: string, options
|
||||
disconnected: false,
|
||||
enrolledAt: new Date().toISOString(),
|
||||
...(options.host ? { host: options.host } : {}),
|
||||
manual: true,
|
||||
refusal: null,
|
||||
service: null,
|
||||
source: 'manual',
|
||||
@@ -357,7 +381,7 @@ export function describeRelayStore(payload: BasePayload, options: ResolvedRelayO
|
||||
* (`/v1/status`); otherwise what was last stored is returned and nothing leaves the server.
|
||||
*/
|
||||
export async function getRelayStatus(payload: BasePayload, options: ResolvedRelayOptions, { refresh = false }: { refresh?: boolean } = {}): Promise<{ error?: string } & RelayStatus> {
|
||||
if (!refresh) {return describeRelayStore(payload, options, await readRelayStore(payload))}
|
||||
if (!refresh) {return describeRelayStore(payload, options, await readSiteStore(payload, options))}
|
||||
const { error, stored } = await refreshRelayStatus(payload, options)
|
||||
return { ...describeRelayStore(payload, options, stored), ...(error && error.code !== LOCAL_CODES.noToken ? { error: error.code } : {}) }
|
||||
}
|
||||
|
||||
@@ -33,8 +33,10 @@ export type RelayStored = {
|
||||
/** An admin pressed "Disconnect": no send and no enrolment until "Connect again". */
|
||||
disconnected?: boolean
|
||||
enrolledAt?: string
|
||||
/** The host the token was issued for. */
|
||||
/** The host the token was issued for. A store found on another host is not this site's (readOwnRelayStore). */
|
||||
host?: string
|
||||
/** The token was issued by hand: the site cannot be called back, so it never enrols by itself to heal. */
|
||||
manual?: boolean
|
||||
/** The last warning about the sender name: the name the mail left under instead. */
|
||||
nameReplaced?: { asked: string; at: string; used: string } | null
|
||||
/** The last refusal of an enrolment; no new enrolment by itself before `until`. */
|
||||
@@ -94,6 +96,32 @@ export async function readRelayStore(payload: BasePayload): Promise<RelayStored>
|
||||
return value && typeof value === 'object' ? { ...value, v: 1 } : { v: 1 }
|
||||
}
|
||||
|
||||
let warnedForeign = false
|
||||
|
||||
/**
|
||||
* The entry of THIS site. A token belongs to the host it was issued for: when the store was made on
|
||||
* another host — a production database copied to a staging domain, a site moved to a new domain — the
|
||||
* token, the candidate and everything known about the service are forgotten here (nothing is revoked:
|
||||
* the other site keeps working), and this site starts unenrolled and enrols as itself.
|
||||
* An entry without a host (a token stored by a script) gets this site's host on first use.
|
||||
*/
|
||||
export async function readOwnRelayStore(payload: BasePayload, host: string): Promise<RelayStored> {
|
||||
const stored = await readRelayStore(payload)
|
||||
if (!host) {return stored}
|
||||
if (stored.host && stored.host !== host) {
|
||||
if (!warnedForeign) {
|
||||
warnedForeign = true
|
||||
payload.logger?.warn?.(`[iapl] mail service: the stored connection belongs to "${stored.host}", this site is "${host}" (a copied database, or a new domain). It is not used here; the site enrols as itself.`)
|
||||
}
|
||||
const kv = kvOf(payload)
|
||||
await kv.delete(CANDIDATE_KEY)
|
||||
await kv.delete(RELAY_KV_KEY)
|
||||
return { v: 1 }
|
||||
}
|
||||
if (stored.token && !stored.host) {return updateRelayStore(payload, (current) => ({ ...current, host }))}
|
||||
return stored
|
||||
}
|
||||
|
||||
/** Reads the entry again, applies `change` and writes it: the smallest window for two writers. */
|
||||
export async function updateRelayStore(payload: BasePayload, change: (current: RelayStored) => RelayStored): Promise<RelayStored> {
|
||||
const next = change(await readRelayStore(payload))
|
||||
|
||||
@@ -53,7 +53,7 @@ export async function askAnswers(ask: Ask): Promise<StarterAnswers> {
|
||||
const collections = (await list(' Collections with their own URLs: posts, caseStudies', 'none')) as ContentCollection[]
|
||||
const forms = await list('5. Forms', 'Contact form')
|
||||
const recipient = await text(' Inbox that receives submissions')
|
||||
const transport = await choice(' E-mail: relay = the built-in mail service (no setup), smtp = the client asked for its own server', ['relay', 'smtp'] as const, 'relay')
|
||||
const transport = await choice(' E-mail: relay = the Intecion mail service, IWSN (no setup), smtp = the client asked for its own server', ['relay', 'smtp'] as const, 'relay')
|
||||
const tools = (await list('6. Analytics: ga4, gtm, metaPixel, linkedIn, tiktok, clarity', 'ga4')) as AnalyticsTool[]
|
||||
const consentMode = await choice(' Consent Mode', ['advanced', 'basic'] as const, 'advanced')
|
||||
const banner = await choice(' Cookie settings window', ['detailed', 'modal', 'inline'] as const, 'detailed')
|
||||
|
||||
Reference in New Issue
Block a user