TrinityCore
Loading...
Searching...
No Matches
AccountService.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "AccountService.h"
20#include "Session.h"
21
23{
24namespace V1
25{
27{
28}
29
30uint32 Account::HandleGetAccountState(account::v1::GetAccountStateRequest const* request, account::v1::GetAccountStateResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/)
31{
32 if (!_session->IsAuthed())
33 return ERROR_DENIED;
34
35 if (request->options().field_privacy_info())
36 {
37 response->mutable_state()->mutable_privacy_info()->set_is_using_rid(false);
38 response->mutable_state()->mutable_privacy_info()->set_is_visible_for_view_friends(false);
39 response->mutable_state()->mutable_privacy_info()->set_is_hidden_from_friend_finder(true);
40
41 response->mutable_tags()->set_privacy_info_tag(0xD7CA834D);
42 }
43
44 return ERROR_OK;
45}
46
47uint32 Account::HandleGetGameAccountState(account::v1::GetGameAccountStateRequest const* request, account::v1::GetGameAccountStateResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/)
48{
49 if (!_session->IsAuthed())
50 return ERROR_DENIED;
51
52 if (request->options().field_game_level_info())
53 {
54 if (GameAccountInfo const* gameAccountInfo = _session->GetGameAccountInfo(request->game_account_id().low()))
55 {
56 response->mutable_state()->mutable_game_level_info()->set_name(gameAccountInfo->DisplayName);
57 response->mutable_state()->mutable_game_level_info()->set_program(ClientBuild::Program::WoW);
58 }
59
60 response->mutable_tags()->set_game_level_info_tag(0x5C46D483);
61 }
62
63 if (request->options().field_game_status())
64 {
65 if (GameAccountInfo const* gameAccountInfo = _session->GetGameAccountInfo(request->game_account_id().low()))
66 {
67 response->mutable_state()->mutable_game_status()->set_is_suspended(gameAccountInfo->IsBanned);
68 response->mutable_state()->mutable_game_status()->set_is_banned(gameAccountInfo->IsPermanenetlyBanned);
69 response->mutable_state()->mutable_game_status()->set_suspension_expires(uint64(gameAccountInfo->UnbanDate) * 1000000);
70 }
71
72 response->mutable_state()->mutable_game_status()->set_program(ClientBuild::Program::WoW);
73 response->mutable_tags()->set_game_status_tag(0x98B75F99);
74 }
75
76 return ERROR_OK;
77}
78}
79
80namespace V2
81{
83{
84}
85
86uint32 Account::HandleGetAccountInfo(account::v2::client::GetAccountInfoRequest const* /*request*/,
87 account::v2::client::GetAccountInfoResponse* response,
88 std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)>& /*continuation*/)
89{
90 account::v2::AccountInfo* info = response->mutable_info();
91
92 info->set_account_id(_session->GetAccountId());
93 info->add_flags(account::v2::AccountInfo::FLAG_IS_HIDDEN_FROM_FRIEND_FINDER);
94
95 return ERROR_OK;
96}
97
98uint32 Account::HandleGetRestriction(account::v2::client::GetRestrictionRequest const* /*request*/,
99 account::v2::client::GetRestrictionResponse* /*response*/,
100 std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)>& /*continuation*/)
101{
102 return ERROR_OK;
103}
104
105uint32 Account::HandleGetGameAccountInfo(account::v2::client::GetGameAccountInfoRequest const* request,
106 account::v2::client::GetGameAccountInfoResponse* response,
107 std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)>& /*continuation*/)
108{
109 if (request->has_game_account())
110 {
111 if (GameAccountInfo const* gameAccountInfo = _session->GetGameAccountInfo(request->game_account().id()))
112 {
113 account::v2::GameAccountInfo* info = response->mutable_info();
114 info->set_account_id(request->game_account().id());
115 info->set_name(gameAccountInfo->DisplayName);
116 }
117 }
118
119 return ERROR_OK;
120}
121
122uint32 Account::HandleGetGameAccountRestriction(account::v2::client::GetGameAccountRestrictionRequest const* request,
123 account::v2::client::GetGameAccountRestrictionResponse* response,
124 std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)>& /*continuation*/)
125{
126 if (request->has_game_account())
127 {
128 if (GameAccountInfo const* gameAccountInfo = _session->GetGameAccountInfo(request->game_account().id()))
129 {
130 if (gameAccountInfo->IsPermanenetlyBanned)
131 {
132 account::v2::Restriction* restriction = response->add_restrictions();
133 restriction->set_title_id(ClientBuild::Program::WoW);
134 restriction->set_type(account::v2::RESTRICTION_TYPE_LOGIN_BANNED);
135 restriction->set_created_time_ms(gameAccountInfo->BanDate * IN_MILLISECONDS);
136 }
137
138 if (gameAccountInfo->IsBanned)
139 {
140 account::v2::Restriction* restriction = response->add_restrictions();
141 restriction->set_title_id(ClientBuild::Program::WoW);
142 restriction->set_type(account::v2::RESTRICTION_TYPE_LOGIN_SUSPENDED);
143 restriction->set_created_time_ms(gameAccountInfo->BanDate * IN_MILLISECONDS);
144 restriction->set_expire_time_ms(gameAccountInfo->UnbanDate * IN_MILLISECONDS);
145 }
146 }
147 }
148
149 return ERROR_OK;
150}
151}
152}
@ IN_MILLISECONDS
Definition Common.h:38
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
uint32 HandleGetAccountState(account::v1::GetAccountStateRequest const *request, account::v1::GetAccountStateResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetGameAccountState(account::v1::GetGameAccountStateRequest const *request, account::v1::GetGameAccountStateResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetRestriction(account::v2::client::GetRestrictionRequest const *request, account::v2::client::GetRestrictionResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetGameAccountInfo(account::v2::client::GetGameAccountInfoRequest const *request, account::v2::client::GetGameAccountInfoResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetGameAccountRestriction(account::v2::client::GetGameAccountRestrictionRequest const *request, account::v2::client::GetGameAccountRestrictionResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetAccountInfo(account::v2::client::GetAccountInfoRequest const *request, account::v2::client::GetAccountInfoResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 GetAccountId() const
Definition Session.h:100
bool IsAuthed() const
Definition Session.h:94
GameAccountInfo const * GetGameAccountInfo() const
Definition Session.h:104
static constexpr Id WoW