public PingbackServiceResponse ProcessReceivedPingback(PingRequest req, Func <bool> ifTargetResourceExists, Func <bool> ifAlreadyBeenPinged) { try { if (null == req) { return(PingbackServiceResponse.InvalidPingRequest); } var ti = ifTargetResourceExists(); if (!ti) { return(PingbackServiceResponse.Error32TargetUriNotExist); } var pd = ifAlreadyBeenPinged(); if (pd) { return(PingbackServiceResponse.Error48PingbackAlreadyRegistered); } if (req.SourceDocumentInfo.SourceHasLink && !req.SourceDocumentInfo.ContainsHtml) { Logger.LogInformation("Adding received pingback..."); var domain = GetDomain(_sourceUrl); OnPingSuccess?.Invoke(this, new PingSuccessEventArgs(domain, req)); return(PingbackServiceResponse.Success); } if (!req.SourceDocumentInfo.SourceHasLink) { Logger.LogError("Pingback error: The source URI does not contain a link to the target URI, and so cannot be used as a source."); return(PingbackServiceResponse.Error17SourceNotContainTargetUri); } Logger.LogWarning("Spam detected on current Pingback..."); return(PingbackServiceResponse.SpamDetectedFakeNotFound); } catch (Exception ex) { Logger.LogError(ex, nameof(ProcessReceivedPingback)); return(PingbackServiceResponse.GenericError); } }
/// <summary> /// /// </summary> protected void RaisePingSuccess <T>(Client server, T response = null) where T : class { OnPingSuccess?.Invoke(this, new ClientHttpEventArgs <T>(server, response)); }