| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using molilian.core;
- using dodohold.core;
- using Microsoft.AspNetCore.Mvc;
- using System.Text.Json;
- namespace molilian.api.Controllers
- {
- [ApiController]
- [Route("[controller]/[action]")]
- public class ForwardController : ControllerBase
- {
- protected IHttpContextAccessor _accessor;
- public ForwardController(IHttpContextAccessor accessor)
- {
- _accessor = accessor;
- }
- //https://api.molilian.vip/forward/qyapi2ntfy/5Sq9BytXXM5WDY3G
- [HttpPost]
- public ActionResult qyapi2ntfy(string url, [FromBody] JsonElement form)
- {
- int errcode = 0;
- string errmsg = "ok";
- string publish_url = string.Empty, topic = string.Empty;
- if (string.IsNullOrEmpty(url))
- {
- errcode = 93000;
- errmsg = "Invalid ntfy server or topic";
- return new APIResult(new { errmsg, errcode });
- }
- string msgtype = form.Read("msgtype", string.Empty);
- switch (msgtype)
- {
- case "text":
- {
- string content = form.PathRead("text.content", string.Empty);
- NifyPlus.Send(url, new NifyMessage
- {
- message = content,
- });
- break;
- }
- case "markdown":
- {
- string content = form.PathRead("markdown.content", string.Empty);
- NifyPlus.Send(url, new NifyMessage
- {
- markdown = true,
- message = content,
- });
- /*
- {
- "topic": "sTXE2kwKp9u8tgnM",
- "message": "#### \u6D88\u606F\u901A\u9053\u914D\u7F6E\u63D0\u9192\n \u003E\u670D\u52A1\u5668\uFF1A\u5B9D\u5854Linux\u9762\u677F\n \u003EIP\u5730\u5740\uFF1A127.0.0.1(\u5916) 89.58.28.154(\u5185)\n \u003E\u53D1\u9001\u65F6\u95F4\uFF1A2024-04-07 12:58:42\n \u003E\u914D\u7F6E\u72B6\u6001\uFF1A\u003Cfont color=#20a53a\u003E\u6210\u529F\u003C/font\u003E",
- "title": "",
- "tags": [],
- "priority": 3,
- "click": "",
- "attach": "",
- "markdown": true,
- "icon": ""
- }
- */
- break;
- }
- }
- new LoggerLibrary("forward", "qyapi2ntfy").Info(form.Convert2Json()).Save();
- return new APIResult(new { errmsg, errcode });
- }
- }
- }
|