no message
This commit is contained in:
parent
56e11c9215
commit
e2f88d1980
@ -30,6 +30,67 @@ public function find(Request $oRequest)
|
||||
return response()->json($oArticle);
|
||||
}
|
||||
|
||||
public function receive(Request $oRequest)
|
||||
{
|
||||
$aArticle = $oRequest->input("_raw");
|
||||
$sTitle = $aArticle["name"] ?? "";
|
||||
$sSchema = $aArticle["schema"] ?? "";
|
||||
$sSlug = "m".$aArticle["id"];
|
||||
|
||||
$sOpt = $aArticle["opt"] ?? "[]";
|
||||
$aOpt = json_decode($sOpt, true);
|
||||
|
||||
$iOptIsTop = $aOpt["iIsTop"] ?? 0;
|
||||
$sOptCategoryName = $aOpt["sCategoryName"] ?? "";
|
||||
$sOptTag = $aOpt["tag"] ?? "";
|
||||
$aOptTag = explode(",", $sOptTag);
|
||||
|
||||
$oCategory = Categories::where("sName", $sOptCategoryName)->first();
|
||||
|
||||
if (!$oCategory) {
|
||||
$sMsg = "不存在的文章分类:{$sOptCategoryName}";
|
||||
TeleSlave::fail()->send($sMsg);
|
||||
exit($sMsg);
|
||||
}
|
||||
|
||||
$aPutField = [
|
||||
"iCategoryId" => $oCategory->id,
|
||||
"iLikeCount" => $aOpt["iLikeCount"] ?? "skip",
|
||||
"i7like" => $aOpt["i7like"] ?? "skip",
|
||||
"i365like" => $aOpt["i365like"] ?? "skip",
|
||||
"iIsTop" => $aOpt["iIsTop"] ?? "skip",
|
||||
];
|
||||
|
||||
$oArticle = Articles::where("sSlug", $sSlug)->first();
|
||||
|
||||
if (!$oArticle) {
|
||||
$oArticle = new Articles();
|
||||
$oArticle->sSlug = $sSlug;
|
||||
}
|
||||
|
||||
foreach ($aPutField as $k => $v) {
|
||||
if ($v !== "skip") {
|
||||
$oArticle->{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$oArticle->save();
|
||||
|
||||
(new TagService())->syncArticleTagsByName($oArticle, $aOptTag);
|
||||
|
||||
$aArticle = $oArticle->toArray();
|
||||
unset($aArticle["sContent"]);
|
||||
unset($aArticle["sTitleSub"]);
|
||||
$jArticle = json_encode($aArticle, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
||||
|
||||
$sMsg = "文章put成功~\n\n{$jArticle}";
|
||||
TeleSlave::notify()->send($sMsg);
|
||||
|
||||
return [
|
||||
"isDone" => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function receiveFreenode(Request $oRequest)
|
||||
{
|
||||
|
||||
@ -93,3 +154,34 @@ public function receiveFreenode(Request $oRequest)
|
||||
return response()->json($oFlow->done());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//array(13) {
|
||||
// ["id"]=>
|
||||
// int(134)
|
||||
// ["code"]=>
|
||||
// string(15) "fn_b-1773480551"
|
||||
// ["name"]=>
|
||||
// string(1) "1"
|
||||
// ["schema"]=>
|
||||
// string(1) "1"
|
||||
// ["schema_pro"]=>
|
||||
// NULL
|
||||
// ["group_code"]=>
|
||||
// string(4) "fn_b"
|
||||
// ["cmd"]=>
|
||||
// string(114) "{"|fn_b|vfnfull|20260314172911|":{"site_code":"vfnfull","cmd":"put","value":"value","date":"2026-03-14 17:29:11"}}"
|
||||
// ["cmd_log"]=>
|
||||
// NULL
|
||||
// ["opt"]=>
|
||||
// string(95) "{"sCategoryName":"Windows","iIsTop":0,"iLikeCount":0,"i7like":0,"i365like":0,"tag":"clash,ssr"}"
|
||||
// ["enable_sync"]=>
|
||||
// int(1)
|
||||
// ["status"]=>
|
||||
// int(1)
|
||||
// ["created_at"]=>
|
||||
// string(27) "2026-03-14T09:29:11.000000Z"
|
||||
// ["updated_at"]=>
|
||||
// string(27) "2026-03-14T09:29:11.000000Z"
|
||||
//}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
use App\Http\Controllers\Api\v1\FreenodeController as ApiV1FreenodeController;
|
||||
|
||||
Route::post('/api/article/receive/freenode', [ApiV1ArticlesController::class, 'receiveFreenode']);
|
||||
Route::post('/api/article/receive', [ApiV1ArticlesController::class, 'receive']);
|
||||
//Route::post('/api/freenode/receive', [ApiV1FreenodeController::class, 'receive']);
|
||||
Route::post('/api/article/find', [ApiV1ArticlesController::class, 'find']);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user