Merge pull request #347 from ChrispyBacon-dev/unstable
Some checks failed
Docker Image - DockFlare / build_self_hosted (push) Has been cancelled
Docker Image - Mail Manager / build_self_hosted (push) Has been cancelled
Docker Image - DockFlare / build_github_hosted_fallback (push) Has been cancelled
Docker Image - Mail Manager / build_github_hosted_fallback (push) Has been cancelled

hotfixes
This commit is contained in:
Chris 2026-04-21 18:31:55 +02:00 committed by GitHub
commit f93a856cae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 5 deletions

View file

@ -60,6 +60,20 @@ def enable_email_routing(zone_id):
logging.error(f"Error enabling email routing: {e}")
raise
def enable_email_sending(zone_id, zone_name):
try:
subdomain = f"mail.{zone_name}"
res = cf_api_request('POST', f'/zones/{zone_id}/email/sending/subdomains', data={"name": subdomain})
logging.info(f"Email sending enabled for {zone_name} (subdomain: {subdomain})")
return res
except Exception as e:
err_str = str(e)
if 'already exists' in err_str.lower() or '2004' in err_str or 'duplicate' in err_str.lower():
logging.info(f"Email sending subdomain already exists for {zone_name}, continuing")
return {}
logging.warning(f"Could not enable email sending for {zone_name} (may require manual activation in CF Dashboard): {e}")
return None
def get_email_routing_status(zone_id):
try:
res = cf_api_request('GET', f'/zones/{zone_id}/email/routing')
@ -176,11 +190,13 @@ def create_r2_bucket(bucket_name):
raise
def get_r2_s3_credentials():
import hashlib
token_verify = cf_api_request('GET', f'/accounts/{config.CF_ACCOUNT_ID}/tokens/verify')
token_id = token_verify.get('result', {}).get('id', '')
secret = hashlib.sha256(config.CF_API_TOKEN.encode()).hexdigest()
return {
'access_key_id': token_id,
'secret_access_key': config.CF_API_TOKEN,
'secret_access_key': secret,
'endpoint_url': f"https://{config.CF_ACCOUNT_ID}.r2.cloudflarestorage.com"
}

View file

@ -2496,9 +2496,9 @@ async function emailVerifyDns(domain, event) {
}
async function emailUpdateR2(domain, event) {
const accessKeyId = prompt('R2 Access Key ID (from CF Dashboard → R2 → Manage R2 API Tokens):');
const accessKeyId = await dfPrompt('R2 Access Key ID (from CF Dashboard → R2 → Manage R2 API Tokens):', '', 'R2 Access Key ID');
if (!accessKeyId) return;
const secretAccessKey = prompt('R2 Secret Access Key:');
const secretAccessKey = await dfPrompt('R2 Secret Access Key:', '', 'R2 Secret Access Key');
if (!secretAccessKey) return;
const btn = event?.currentTarget;
const originalHTML = btn?.innerHTML;

View file

@ -137,7 +137,7 @@ def setup_email_domain():
outbound_auth_secret = secrets.token_hex(32)
inbound_worker_name = f"dockflare-mail-inbound-{zone_name.replace('.', '-')}"
outbound_worker_name = f"dockflare-mail-outbound-{zone_name.replace('.', '-')}"
webmail_hostname = f"mail.{zone_name}"
webmail_hostname = _get_webmail_hostname() or f"mail.{zone_name}"
webhook_url = f"https://{webmail_hostname}/api/v1/webhook/inbound"
quota_kv_ns_id = None
@ -164,6 +164,11 @@ def setup_email_domain():
email_manager.set_worker_cron(inbound_worker_name, ['*/5 * * * *'])
email_manager.setup_catchall_routing_rule(zone_id, inbound_worker_name)
try:
email_manager.enable_email_sending(zone_id, zone_name)
except Exception as sending_err:
logging.warning(f"Could not enable email sending for {zone_name} (may need manual enable in CF Dashboard): {sending_err}")
outbound_bindings = [
{"type": "send_email", "name": "SEND_EMAIL"},
{"type": "secret_text", "name": "AUTH_SECRET", "text": outbound_auth_secret}
@ -389,7 +394,7 @@ def _redeploy_outbound_worker(email_cfg, domain):
def _redeploy_inbound_worker(email_cfg, domain):
d = email_cfg['domains'][domain]
all_addresses = list(d['mailboxes'].keys())
webmail_hostname = f"mail.{domain}"
webmail_hostname = _get_webmail_hostname() or f"mail.{domain}"
webhook_url = f"https://{webmail_hostname}/api/v1/webhook/inbound"
kv_ns_id = d.get('quota_kv_namespace_id')

View file

@ -104,6 +104,7 @@ def wipe_domain():
for row in rows:
shutil.rmtree(os.path.join(config.ATTACHMENTS_PATH, str(row['id'])), ignore_errors=True)
conn.execute("DELETE FROM mailboxes WHERE address LIKE ?", (f'%@{domain}',))
conn.execute("DELETE FROM domain_configs WHERE domain_name=?", (domain,))
conn.commit()
conn.close()
def _vacuum():
@ -131,6 +132,7 @@ def wipe_all():
conn = sqlite3.connect(db_path)
conn.execute("PRAGMA foreign_keys=ON")
conn.execute("DELETE FROM mailboxes")
conn.execute("DELETE FROM domain_configs")
conn.commit()
conn.close()
def _vacuum():