Reorganized and cleaned up the solution.

This commit is contained in:
HikikoMarmy
2026-03-02 12:37:07 +00:00
parent 8012f30170
commit d4dfbddf69
175 changed files with 1516 additions and 1136 deletions

View File

@@ -0,0 +1,61 @@
#include "Network/Event/RequestAddIgnore.hpp"
#include "Game/RealmUserManager.hpp"
#include "Database/Database.hpp"
#include "logging.hpp"
void RequestAddIgnore::Deserialize( sptr_byte_stream stream )
{
DeserializeHeader( stream );
m_sessionId = stream->read_encrypted_utf16();
m_chatHandle = stream->read_utf16();
}
sptr_generic_response RequestAddIgnore::ProcessRequest( sptr_socket socket, sptr_byte_stream stream )
{
Deserialize( stream );
auto user = UserManager::Get().FindUserBySocket( socket );
if( user == nullptr )
{
return std::make_shared< ResultAddIgnore >( this, FATAL_ERROR );
}
if( user->IsFriend( m_chatHandle ) )
{
return std::make_shared< ResultAddIgnore >( this, IGNORE_FRIEND );
}
if( user->IsIgnored( m_chatHandle ) )
{
return std::make_shared< ResultAddIgnore >( this, IGNORE_DUPLICATE );
}
auto targetUser = UserManager::Get().FindUserByChatHandle( m_chatHandle );
if( targetUser == nullptr )
{
return std::make_shared< ResultAddIgnore >( this, IGNORE_INVALID );
}
if( !Database::Get().SaveIgnore( user->m_accountId, targetUser->m_chatHandle ) )
{
return std::make_shared< ResultAddIgnore >( this, DATABASE_ERROR );
}
user->m_ignoreList.push_back( targetUser->m_chatHandle );
return std::make_shared< ResultAddIgnore >( this, SUCCESS );
}
ResultAddIgnore::ResultAddIgnore( GenericRequest *request, int32_t reply ) : GenericResponse( *request )
{
m_reply = reply;
}
void ResultAddIgnore::Serialize( ByteBuffer &out ) const
{
out.write_u16( m_packetId );
out.write_u32( m_trackId );
out.write_u32( m_reply );
}