Confirm when joining a public relay

This commit is contained in:
Jon Staab
2024-10-10 17:49:42 -07:00
parent 46965f5945
commit fa7852113b
6 changed files with 84 additions and 21 deletions

View File

@@ -214,20 +214,22 @@ export const checkRelayProfile = async (url: string) => {
export const checkRelayConnection = async (url: string) => {
const connection = ctx.net.pool.get(url)
const okStatuses = [ConnectionStatus.Ok, ConnectionStatus.Slow, ConnectionStatus.Unauthorized]
await connection.ensureConnected()
if (![ConnectionStatus.Ok, ConnectionStatus.Slow].includes(connection.meta.getStatus())) {
if (!okStatuses.includes(connection.meta.getStatus())) {
return `Failed to connect: "${connection.meta.getDescription()}"`
}
}
export const checkRelayAuth = async (url: string) => {
const connection = ctx.net.pool.get(url)
const okStatuses = [AuthStatus.Ok, AuthStatus.Pending]
await connection.ensureAuth()
if (![AuthStatus.Ok, AuthStatus.Pending].includes(connection.meta.authStatus)) {
if (!okStatuses.includes(connection.meta.authStatus)) {
return `Failed to authenticate: "${connection.meta.authStatus}"`
}
}