public async Task <IActionResult> AddGroupMessageHandlerAsync([Required] int robotQQ, CancellationToken token) { IMiraiHttpSession session = await _robotManager.RetriveSessionAsync(robotQQ, token); session.AddPlugin(new GroupMessageHandler()); return((JsonResult)ResponseModel.CreateSuccess()); }
public async Task <IActionResult> MediaMetadata(string downloadLink) { if (string.IsNullOrWhiteSpace(downloadLink) || !Uri.TryCreate(downloadLink, UriKind.Absolute, out _)) { return(Json(ResponseModel <MediaMetadata> .CreateFailure("Invalid Media URL"))); } var existingMetadataForDownloadLink = await _vidloadCache.GetMetadata(downloadLink); if (existingMetadataForDownloadLink.IsSuccess && existingMetadataForDownloadLink.Value.HasValue) { return(Json(ResponseModel <MediaMetadata> .CreateSuccess(existingMetadataForDownloadLink.Value.Value))); } return(Json(ResponseModel <MediaMetadata> .CreateSuccess(null))); }
public async Task <IActionResult> InitiateDownload([FromBody] DownloadRequest downloadRequest) { if (!downloadRequest.IsValid()) { return(Json(ResponseModel <object> .CreateFailure("The request is invalid and does not meet the API-Requirements"))); } var userId = "Anonymous"; var traceId = Guid.NewGuid().ToString(); var downloadLink = downloadRequest.DownloadLink.Trim(); var downloadJobState = await _vidloadCache.GetJobStatus(downloadLink); if (downloadJobState.IsSuccess && downloadJobState.Value.HasValue) { return(Json(ResponseModel <object> .CreateSuccess(null))); } var existingMetaData = await _vidloadCache.GetMetadata(downloadLink); if (existingMetaData.IsSuccess && existingMetaData.Value.HasNoValue) { await _jobEnqueuer.Enqueue(new MediaMetadataJob { DownloadLink = downloadLink, TraceId = traceId, UserId = userId }); } var existingFileLocation = await _vidloadCache.GetMediaLocation(downloadLink); if (existingFileLocation.IsSuccess && existingFileLocation.Value.HasNoValue) { var targetFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), downloadRequest.OutputFormat, true); await _jobEnqueuer.Enqueue(new MediaDownloadJob { DownloadLink = downloadLink, TraceId = traceId, UserId = userId, TargetFormat = targetFormat }); } await _vidloadCache.SetJobStatus(traceId, JobStatus.Enqueued); return(Json(ResponseModel <object> .CreateSuccess(null))); }
public async Task <IActionResult> AddAsync([Required] int robotQQ, CancellationToken token) { await _robotManager.RetriveSessionAsync(robotQQ, token); return((JsonResult)ResponseModel.CreateSuccess()); }