Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06104b77b3 | ||
|
|
176f653a33 | ||
|
|
3fdf6fc522 |
No files matched your search
@@ -6,4 +6,15 @@
|
||||
|
||||
RenumberTitles仅为本次明确授权的历史修复入口,无公开HTTP写接口。备份原Markdown和账本,标题元数据更新后一次构建,失败恢复原文件;成功后将同一批准ID的TTC原回执和ATOM已发布artifact/approved_hash同步为仅标题修复后的精确版本,并记录previous_artifact_hash。不重发文章,不新增批准,不改变TG审核决定。
|
||||
|
||||
线上念云目前仅两篇:旧篇“念云机场测速”,指定新篇“念云机场测速(第2次)”;下一篇才是第3次。运行、构建和HTTP验收随后补录。临时暂停ATOM content worker进行历史修复,结束恢复;调度与其他队列不变。代码按Git提交推送部署,私有数据备份在目标服务器root私有部署目录,运行账本在TTC storage/app/private/content-center/title-series.json。
|
||||
线上念云目前仅两篇:旧篇“念云机场测速”,指定新篇“念云机场测速(第2次)”;下一篇才是第3次。代码与历史迁移已上线。临时暂停ATOM content worker进行历史修复,结束恢复;调度与其他队列不变。代码按Git提交推送部署,私有数据备份在目标服务器root私有部署目录,运行账本在TTC storage/app/private/content-center/title-series.json。
|
||||
|
||||
|
||||
## 最终验收
|
||||
|
||||
2026-10-26生产TTC代码468121f、ATOM代码c5c6c4d。历史88篇标题/系列字段已迁移,88份正文及88份其余元数据(日期/评分/标签/编号/永久链接等)逐份完全一致,重复编号0、错误格式0;念云旧篇无括号,指定新篇第2次,下一篇预览第3次。两篇已发布稿的ATOM artifact/approved_hash与TTC原批准回执和Markdown精确一致,真实签名预览API回读也两份一致。目标公开页面HTTP200并包含“念云机场测速(第2次)”。内容worker已恢复,无新增发布或TG决定。
|
||||
|
||||
TTC有效回归56测试/215断言通过(1项既有依赖弃用提示);原ExampleTest引用已不存在的laravel/atom-admin/bootstrap/app.php,未改无关历史示例。ATOM完整94测试/506断言通过。
|
||||
|
||||
备份:/var/lib/ttc-deploy/title-series-20261026/before-atom.sql与before-published.json;TTC private/content-center/title-migration-20261026.json保留全部旧Markdown及旧账本。迁移只改标题相关字段,编号账本为运行数据;文章不是重新采集/发布。构建失败尝试已回滚;最终一次构建成功后同步原回执,不伪造新批准。
|
||||
|
||||
部署差异:TTC现有安装仍缓存Pail提供者,dump-autoload不强行使用--no-dev,避免与既有安装/缓存不一致;未升级或安装依赖。root私有Node需要完整运行身份/附加组,单独切有效UID不足以模拟服务账号;最终以部署身份构建,公开产物、生成缓存和账本交回www-data。已用runuser实测现有Node版本v24.11.1可执行,未放宽/root权限。已完成服务器侧验收,未做线上页面验收。
|
||||
@@ -37,6 +37,7 @@ final class HttpQueue
|
||||
$oTgSlave = TelegramSlave::start()
|
||||
->enableMaster(true)
|
||||
->enableAsync(false)
|
||||
->forOperationsQueueRow((int) $oHttpQueueRow->id)
|
||||
->enableSlaveQueue(false)
|
||||
->setBotCode($sBotCode)
|
||||
->setChatCode($sChatCode)
|
||||
|
||||
@@ -94,7 +94,7 @@ class Slave
|
||||
// new
|
||||
public static function notify(string $sChatCode = 'admin'): self
|
||||
{
|
||||
return self::start("fail", $sChatCode);
|
||||
return self::start("notification", $sChatCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -233,50 +233,29 @@ class Slave
|
||||
$aData = $this->buildDataTom();
|
||||
|
||||
if ($this->enableSlaveQueue) {
|
||||
$oFlow = ServiceHttpQueue::start("telegram_master")->arg($aData)->save();
|
||||
} else {
|
||||
|
||||
$oFlow = Flow::start("_send_master");
|
||||
$sUrlMaSterBase = $_ENV["url_master_base"];
|
||||
|
||||
if (!$sUrlMaSterBase) {
|
||||
throw new Exception("未设置env的url_master_base");
|
||||
}
|
||||
|
||||
$sUrlMasterPost = "https://".$sUrlMaSterBase."/api/telegram/post";
|
||||
|
||||
try {
|
||||
|
||||
$oHttpV2 = HttpV2::make($sUrlMasterPost);
|
||||
|
||||
if ($this->enableAsync) {
|
||||
$oHttpV2 = $oHttpV2->enableAsync();
|
||||
}
|
||||
|
||||
$r = $oHttpV2->enableJsonAs()->setData($aData)->send();
|
||||
|
||||
if ($this->enableAsync) {
|
||||
return $oFlow->sData("async")->done("async");
|
||||
} else {
|
||||
$a = json_decode($r, true);
|
||||
$isDone = $a["isDone"] ?? false;
|
||||
|
||||
if ($isDone) {
|
||||
return $oFlow->done();
|
||||
} else {
|
||||
return $oFlow->fail($r);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$oFlow = $oFlow->fail($e->getMessage());
|
||||
}
|
||||
return ServiceHttpQueue::start("telegram_master")->arg($aData)->save();
|
||||
}
|
||||
|
||||
$flow = Flow::start("operations notification");
|
||||
try {
|
||||
$root = dirname(__DIR__, 4);
|
||||
require_once $root . '/ops/AdminNotice.php';
|
||||
$this->operationsEventKey ??= bin2hex(random_bytes(16));
|
||||
$receipts = \LegacyOperations\AdminNotice::submit($root, $aData, $this->operationsEventKey);
|
||||
return $flow->done('TeleHub accepted ' . implode(',', $receipts));
|
||||
} catch (\Throwable $error) {
|
||||
return $flow->fail($error->getMessage());
|
||||
}
|
||||
|
||||
return $oFlow;
|
||||
}
|
||||
|
||||
|
||||
private ?string $operationsEventKey = null;
|
||||
|
||||
public function forOperationsQueueRow(int $id): self
|
||||
{
|
||||
$this->operationsEventKey = 'queue.' . $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _send_local(): Flow
|
||||
{
|
||||
if ($this->enableSlaveQueue) {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LegacyOperations;
|
||||
|
||||
final class AdminNotice
|
||||
{
|
||||
public static function bot(string $code): string
|
||||
{
|
||||
return match ($code) {
|
||||
'log' => 'log',
|
||||
'warn', 'warning' => 'warning',
|
||||
'fail', 'error' => 'error',
|
||||
'notify', 'notification' => 'notification',
|
||||
'base', 'admin', '' => 'base',
|
||||
default => throw new \DomainException('Unregistered operations notification category'),
|
||||
};
|
||||
}
|
||||
|
||||
public static function submit(string $projectRoot, array $data, string $eventKey): array
|
||||
{
|
||||
$target = (string) ($data['sChatCode'] ?? '');
|
||||
if (!in_array($target, ['', 'base', 'admin'], true) || !empty($data['iChatId']) || !empty($data['sBotToken'])) {
|
||||
throw new \DomainException('Explicit Telegram recipients require their own publisher');
|
||||
}
|
||||
if (!empty($data['sPhotoUrl']) || !empty($data['sFileUrl'])) {
|
||||
throw new \DomainException('Attachments require their original publisher');
|
||||
}
|
||||
$configPath = '/etc/telehub-operations/' . hash('sha256', $projectRoot) . '.json';
|
||||
$config = json_decode((string) @file_get_contents($configPath), true, 16, JSON_THROW_ON_ERROR);
|
||||
$bot = self::bot($data['sBotCode'] ?? '');
|
||||
$text = (string) ($data['sMsg'] ?? '');
|
||||
if (trim($text) === '') {
|
||||
throw new \DomainException('Empty operations notification');
|
||||
}
|
||||
$title = '【' . $config['project'] . '/生产 - 运行通知】' . "\n";
|
||||
$room = 4096 - mb_strlen($title, 'UTF-8');
|
||||
$receipts = [];
|
||||
foreach (mb_str_split($text, $room, 'UTF-8') as $part => $body) {
|
||||
$payload = json_encode(['bot' => $bot, 'target' => 'base', 'text' => $title . $body], JSON_THROW_ON_ERROR);
|
||||
$http = curl_init('https://telehub.gemcook.net/api/v1/messages');
|
||||
curl_setopt_array($http, [
|
||||
CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 4, CURLOPT_TIMEOUT => 15, CURLOPT_FOLLOWLOCATION => false,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json', 'Accept: application/json',
|
||||
'Authorization: Bearer ' . $config['key'],
|
||||
'Idempotency-Key: ' . $eventKey . '.' . $part,
|
||||
],
|
||||
]);
|
||||
$response = curl_exec($http);
|
||||
$status = curl_getinfo($http, CURLINFO_RESPONSE_CODE);
|
||||
curl_close($http);
|
||||
$receipt = is_string($response) ? (json_decode($response, true)['data'] ?? []) : [];
|
||||
if (!in_array($status, [200, 202], true) || empty($receipt['id'])) {
|
||||
throw new \RuntimeException('TeleHub submission unconfirmed (HTTP ' . $status . ')');
|
||||
}
|
||||
if (in_array($receipt['status'] ?? '', ['failed', 'uncertain', 'cancelled'], true)) {
|
||||
throw new \RuntimeException('TeleHub delivery requires review: ' . $receipt['id']);
|
||||
}
|
||||
$receipts[] = $receipt['id'];
|
||||
}
|
||||
return $receipts;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\Api\ArticleController as ApiArticleController;
|
||||
use App\Http\Controllers\Api\Tg\HookController;
|
||||
use App\Http\Controllers\HelloController;
|
||||
|
||||
//Route::any('/api/telegram/post', [ServiceOpenApiTelegram::class, 'post']);
|
||||
@@ -10,6 +9,5 @@ use App\Http\Controllers\HelloController;
|
||||
|
||||
Route::get('/', [HelloController::class, 'index']);
|
||||
|
||||
Route::any('/api/tg/hook', [HookController::class, 'cmd']);
|
||||
|
||||
Route::any('/api/article/receive/schema', [ApiArticleController::class, 'receiveSchema']);
|
||||
Reference in new issue
Block a user