@@ -36,14 +36,16 @@ public void OnPluginStart()
36
36
PrintToServer (" [Payload] Plugin loaded." );
37
37
}
38
38
39
- public Action testUpload (int client , int args ){
39
+ public Action testUpload (int client , int args )
40
+ {
40
41
LogUploaded (true , " 2961236" , " https://logs.tf/2961236" );
41
42
return Plugin_Handled ;
42
43
}
43
44
44
45
public int LogUploaded (bool success , const char [] logid , const char [] url )
45
46
{
46
- if (success ) {
47
+ if (success )
48
+ {
47
49
bool sendRequest = GetConVarBool (g_hCvarSendLogs );
48
50
if (sendRequest == false )
49
51
return ;
@@ -73,25 +75,32 @@ public int LogUploaded(bool success, const char[] logid, const char[] url)
73
75
74
76
public void SendRequest (const char [] logid , const char [] fullApiUrl )
75
77
{
76
- Handle hRequest = SteamWorks_CreateHTTPRequest (k_EHTTPMethodPOST ,fullApiUrl );
77
- SteamWorks_SetHTTPRequestHeaderValue (hRequest ," Content-Type" ," x-www-form-urlencoded" );
78
- SteamWorks_SetHTTPRequestGetOrPostParameter (hRequest , " token" , g_sWebhookToken );
78
+ Handle hRequest = SteamWorks_CreateHTTPRequest (k_EHTTPMethodPOST , fullApiUrl );
79
+
80
+ // Headers
81
+ SteamWorks_SetHTTPRequestHeaderValue (hRequest , " Content-Type" , " x-www-form-urlencoded" );
82
+ SteamWorks_SetHTTPRequestHeaderValue (hRequest , " Authorization" , g_sWebhookToken );
83
+
84
+ // Body
79
85
SteamWorks_SetHTTPRequestGetOrPostParameter (hRequest , " logsId" , logid );
80
- SteamWorks_SetHTTPRequestGetOrPostParameter ( hRequest , " requester " , VERSION );
86
+
81
87
SteamWorks_SetHTTPCallbacks (hRequest , OnSteamWorksHTTPComplete );
82
88
SteamWorks_SendHTTPRequest (hRequest );
83
-
84
89
}
85
- public int OnSteamWorksHTTPComplete (Handle hRequest , bool bFailure , bool bRequestSuccessful , EHTTPStatusCode eStatusCode , any data ) {
86
- if (bFailure ){
90
+
91
+ public int OnSteamWorksHTTPComplete (Handle hRequest , bool bFailure , bool bRequestSuccessful , EHTTPStatusCode eStatusCode , any data )
92
+ {
93
+ if (bFailure )
94
+ {
87
95
PrintToChatAll (" [Payload] Unable to post logs preview" );
88
96
PrintToServer (" [Payload] Unable to post logs preview" );
89
- PrintToServer (" Status Code: %i " ,eStatusCode );
97
+ PrintToServer (" Status Code: %i " , eStatusCode );
90
98
}
91
99
else
92
100
{
93
101
PrintToChatAll (" [Payload] Log preview uploaded" );
94
102
PrintToServer (" [Payload] Log preview uploaded" );
95
103
}
104
+
96
105
delete hRequest ;
97
106
}
0 commit comments