2using System.Collections.Generic;
5using System.Threading.Tasks;
20 public override bool HandlesSubPaths =>
false;
21 public override bool UserSessions =>
true;
30 if (!(Obj is Dictionary<string, string> Form))
37 string RecaptchaResponse;
40 if (!Form.ContainsKey(
"Name") ||
string.IsNullOrEmpty(Name = Form[
"Name"]?.Trim()))
43 if (!Form.ContainsKey(
"EMail") ||
string.IsNullOrEmpty(EMail = Form[
"EMail"]?.Trim()))
46 if (!Form.ContainsKey(
"Reason") ||
string.IsNullOrEmpty(Reason = Form[
"Reason"]?.Trim()))
49 if (!Form.ContainsKey(
"Text") ||
string.IsNullOrEmpty(Text = Form[
"Text"]?.Trim()))
52 if (!Form.ContainsKey(
"g-recaptcha-response") ||
string.IsNullOrEmpty(RecaptchaResponse = Form[
"g-recaptcha-response"]))
55 if (!Form.ContainsKey(
"ResponseDesired"))
56 ResponseDesired =
false;
63 new KeyValuePair<string, object>(
"Name", Name),
64 new KeyValuePair<string, object>(
"EMail", EMail),
65 new KeyValuePair<string, object>(
"Reason", Reason),
66 new KeyValuePair<string, object>(
"Text", Text),
67 new KeyValuePair<string, object>(
"ResponseDesired", ResponseDesired),
68 new KeyValuePair<string, object>(
"RemoteEndPoint", Request.
RemoteEndPoint));
70 Dictionary<string, object>
Feedback =
new Dictionary<string, object>();
71 foreach (KeyValuePair<string, object> P
in Tags)
76 StringBuilder Markdown =
new StringBuilder();
77 DateTime Now = DateTime.Now;
79 Markdown.AppendLine(
"Feedback received.");
80 Markdown.AppendLine();
82 Markdown.AppendLine(
"| Feedback ||");
83 Markdown.AppendLine(
"|:------|:-------|");
85 Markdown.Append(
"| Name: | ");
87 Markdown.AppendLine(
" |");
89 Markdown.Append(
"| e-Mail: | <a href=\"mailto:");
90 Markdown.Append(EMail.Replace(
"\"",
"""));
91 Markdown.Append(
"\" target=\"_blank\">");
93 Markdown.AppendLine(
"</a> |");
95 Markdown.Append(
"| Reason: | ");
97 Markdown.AppendLine(
" |");
99 Markdown.Append(
"| Response desired: | ");
101 Markdown.Append(
":white_check_mark:");
103 Markdown.Append(
":negative_squared_cross_mark:");
104 Markdown.AppendLine(
" |");
108 Markdown.Append(
"| Date | ");
110 Markdown.AppendLine(
" |");
111 Markdown.Append(
"| Time | ");
113 Markdown.AppendLine(
" |");
115 Markdown.AppendLine();
116 Markdown.AppendLine();
117 Markdown.AppendLine(
"```");
118 Markdown.AppendLine(Text.Replace(
"```",
" ` ` ` "));
119 Markdown.AppendLine(
"```");
123 await IoTGateway.Gateway.SendNotification(Markdown.ToString());
137 internal static async Task<bool> SiteVerify(
string RecaptchaResponse,
string RemoteEndPoint)
139 using (HttpClient WebClient =
new HttpClient())
141 Dictionary<string, string> VerificationForm =
new Dictionary<string, string>()
143 {
"secret",
"6LcHNh0UAAAAAI1DwveBT21M4IkSRc5i-QciPUvg" },
144 {
"response", RecaptchaResponse },
145 {
"remoteip", RemoteEndPoint }
148 HttpContent Content =
new FormUrlEncodedContent(VerificationForm);
149 HttpResponseMessage ResponseMsg = await WebClient.PostAsync(
"https://www.google.com/recaptcha/api/siteverify", Content);
150 if (!ResponseMsg.IsSuccessStatusCode)
153 string Json = await ResponseMsg.Content.ReadAsStringAsync();
154 return (
JSON.
Parse(Json) is Dictionary<string, object> Parsed && Parsed.ContainsKey(
"success") && Parsed[
"success"] is
bool Success && Success);
Helps with parsing of commong data types.
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Helps with common JSON-related tasks.
static object Parse(string Json)
Parses a JSON string.
Contains a markdown document. This markdown document class supports original markdown,...
static string Encode(string s)
Encodes all special characters in a string so that it can be included in a markdown document without ...
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Represents an HTTP request.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
Variables Session
Contains session states, if the resource requires sessions, or null otherwise.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The response to the request can be found under a different URI and SHOULD be retrieved using a GET me...
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Class that monitors login events, and help applications determine malicious intent....
static async Task< string > AppendWhoIsInfo(StringBuilder Markdown, string RemoteEndpoint)
Appends WHOIS information to a Markdown document.
static async Task< KeyValuePair< string, object >[]> Annotate(string RemoteEndpoint, params KeyValuePair< string, object >[] Tags)
Annotates a remote endpoint.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
Service Module hosting the XMPP broker and its components.
static async Task AppendRemoteEndpointToTable(StringBuilder Markdown, string RemoteEndpoint)
Appends annotated information about a remote endpoint to a Markdown table.
POST Interface for HTTP resources.