Initial import of fitme3070.pt platform
Plain-PHP fleet platform with id.andmore.pt SSO. Wires shared/platform-tools as a submodule (platform_update, backups, git/migration tools) like the other platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
e68d357177
2330 files changed
+215968
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// Outbound delivery — now centralized at id.andmore.pt (/notify).
|
||||
//
|
||||
// fotografia no longer runs its own SMTP/n8n queue. The local `message_queue`
|
||||
// table, the Monitor UI (views/sysadmin/messages.php) and the cron drainer
|
||||
// (api/process_queue.php) were removed when delivery merged into id.andmore.pt.
|
||||
//
|
||||
// This file is a thin compatibility façade so the dozens of existing call sites
|
||||
// keep working unchanged. They use the historical two-step contract:
|
||||
// $id = enqueue_email([...]); // stage the message
|
||||
// return flush_message($id); // send it (now: relay to id.andmore.pt)
|
||||
//
|
||||
// enqueue_*() stages the payload in-request; flush_message() ships it through
|
||||
// notify_remote_send() (see config/functions_notify_client.php) and returns the
|
||||
// real sent/failed result. Bulk callers that loop enqueue+flush still work.
|
||||
|
||||
$GLOBALS['_notify_staged'] = [];
|
||||
$GLOBALS['_notify_seq'] = 0;
|
||||
|
||||
function enqueue_email(array $data): int { return _notify_stage('email', $data); }
|
||||
function enqueue_sms(array $data): int { return _notify_stage('sms', $data); }
|
||||
|
||||
function _notify_stage(string $channel, array $data): int {
|
||||
$id = ++$GLOBALS['_notify_seq'];
|
||||
$GLOBALS['_notify_staged'][$id] = ['channel' => $channel] + $data;
|
||||
return $id;
|
||||
}
|
||||
|
||||
// Relay a staged message to id.andmore.pt and return true on success. The local
|
||||
// `to_user_id` is intentionally NOT forwarded — it's a fotografia id, not a
|
||||
// canonical id.andmore.pt user id (the central queue FK would reject it). The
|
||||
// recipient address + this app's key are enough; the central log records origin.
|
||||
function flush_message(int $id): bool {
|
||||
$data = $GLOBALS['_notify_staged'][$id] ?? null;
|
||||
if (!$data) return false;
|
||||
unset($GLOBALS['_notify_staged'][$id]);
|
||||
|
||||
$channel = $data['channel'] ?? 'email';
|
||||
$payload = [
|
||||
'channel' => $channel,
|
||||
'to' => $data['to_address'] ?? '',
|
||||
'to_name' => $data['to_name'] ?? null,
|
||||
'body' => $data['body'] ?? '',
|
||||
];
|
||||
if ($channel === 'email') {
|
||||
// Preserve the historical subject prefix that the old SMTP path applied.
|
||||
$prefix = defined('EMAIL_SUBJECT_PREFIX') ? EMAIL_SUBJECT_PREFIX : '';
|
||||
$payload['subject'] = $prefix . ($data['subject'] ?? '');
|
||||
$payload['alt_body'] = $data['alt_body'] ?? null;
|
||||
}
|
||||
if (!empty($data['context_type'])) {
|
||||
$payload['context'] = ['type' => $data['context_type'], 'id' => $data['context_id'] ?? null];
|
||||
}
|
||||
if (!empty($data['scheduled_for'])) {
|
||||
$payload['scheduled_for'] = $data['scheduled_for'];
|
||||
}
|
||||
|
||||
$r = notify_remote_send($payload);
|
||||
return !empty($r['ok']) && (($r['status'] ?? '') !== 'failed');
|
||||
}
|
||||
|
||||
// No local queue to drain anymore. Kept as a harmless no-op so any stray caller
|
||||
// (or scheduled task that wasn't updated) doesn't fatal.
|
||||
function process_queue(int $limit = 20): array {
|
||||
return ['sent' => 0, 'failed' => 0, 'total' => 0];
|
||||
}
|
||||
Reference in new issue
Block a user