summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/api/pending.h
blob: 4e971275b43cea36ea93c12d35ff73c276d67a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef _STEAM_REQUEST_PENDING_H_
#define _STEAM_REQUEST_PENDING_H_

class ApprovePendingRequest : public HttpRequest
{
public:
	ApprovePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
		HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId)
	{
		char login[MAX_PATH];
		mir_snprintf(login, _countof(login), "%s||oauth:%s", steamId, token);

		char cookie[MAX_PATH];
		mir_snprintf(cookie, _countof(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);

		char data[MAX_PATH];
		mir_snprintf(data, _countof(data), "sessionID=%s&id=%s&perform=accept&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);

		SetData(data, strlen(data));
		AddHeader("Cookie", cookie);
		AddHeader("Content-Type", "application/x-www-form-urlencoded");
	}
};

class IgnorePendingRequest : public HttpRequest
{
public:
	IgnorePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
		HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId)
	{
		char login[MAX_PATH];
		mir_snprintf(login, _countof(login), "%s||oauth:%s", steamId, token);

		char cookie[MAX_PATH];
		mir_snprintf(cookie, _countof(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);

		char data[MAX_PATH];
		mir_snprintf(data, _countof(data), "sessionID=%s&id=%s&perform=ignore&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);

		SetData(data, strlen(data));
		AddHeader("Cookie", cookie);
		AddHeader("Content-Type", "application/x-www-form-urlencoded");
	}
};

class BlockPendingRequest : public HttpRequest
{
public:
	BlockPendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
		HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId)
	{
		char login[MAX_PATH];
		mir_snprintf(login, _countof(login), "%s||oauth:%s", steamId, token);

		char cookie[MAX_PATH];
		mir_snprintf(cookie, _countof(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);

		char data[MAX_PATH];
		mir_snprintf(data, _countof(data), "sessionID=%s&id=%s&perform=block&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);

		SetData(data, strlen(data));
		AddHeader("Cookie", cookie);
		AddHeader("Content-Type", "application/x-www-form-urlencoded");
	}
};

#endif //_STEAM_REQUEST_PENDING_H_