• R/O
  • SSH
  • HTTPS

ewatch: Commit


Commit MetaInfo

Revision116 (tree)
Zeit2020-08-14 14:28:38
Autorbananajinn

Log Message

* Slack通知はformではなくjsonで送るように変更

Ändern Zusammenfassung

Diff

--- trunk/EWatch/EWatch/Actions/ActionSlack.cs (revision 115)
+++ trunk/EWatch/EWatch/Actions/ActionSlack.cs (revision 116)
@@ -91,15 +91,9 @@
9191 var subject = string.Format("[{0}] {1}", data.HostName, GetSubject(data.Message));
9292 if (!Util.IsNullOrEmpty(data.Name))
9393 subject = string.Format("[{0}]{1}", data.Name, subject);
94- Send(string.Concat("payload=", Encode(GetJSON(subject, text.ToString()))));
94+ Send(GetJSON(subject, text.ToString()));
9595 }
9696
97- private string Encode(string value)
98- {
99- var result = WebUtility.UrlEncode(value);
100- return result.Replace("+", "%20");
101- }
102-
10397 private string GetSubject(string value)
10498 {
10599 if (!string.IsNullOrEmpty(value)) {
@@ -140,12 +134,12 @@
140134 return jo.ToString();
141135 }
142136
143- private string Send(string postData)
137+ private string Send(string payload)
144138 {
145- var data = Encoding.ASCII.GetBytes(postData);
139+ var data = Encoding.UTF8.GetBytes(payload);
146140 var req = (HttpWebRequest)WebRequest.Create(URL);
147141 req.Method = "POST";
148- req.ContentType = "application/x-www-form-urlencoded";
142+ req.ContentType = "application/json;charset=UTF-8";
149143 req.ContentLength = data.Length;
150144
151145 using (Stream s = req.GetRequestStream()) {
Show on old repository browser