mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added in Libresapi: Functions to get and set default identity for lobby
This commit is contained in:
parent
b24d772278
commit
4b25684c44
@ -175,6 +175,10 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
|
||||
addResourceHandler("get_invitations_to_lobby", this, &ChatHandler::handleGetInvitationsToLobby);
|
||||
addResourceHandler("answer_to_invitation", this, &ChatHandler::handleAnswerToInvitation);
|
||||
addResourceHandler("lobby_participants", this, &ChatHandler::handleLobbyParticipants);
|
||||
addResourceHandler("get_default_identity_for_chat_lobby", this, &ChatHandler::handleGetDefaultIdentityForChatLobby);
|
||||
addResourceHandler("set_default_identity_for_chat_lobby", this, &ChatHandler::handleSetDefaultIdentityForChatLobby);
|
||||
addResourceHandler("get_identity_for_chat_lobby", this, &ChatHandler::handleGetIdentityForChatLobby);
|
||||
addResourceHandler("set_identity_for_chat_lobby", this, &ChatHandler::handleSetIdentityForChatLobby);
|
||||
addResourceHandler("messages", this, &ChatHandler::handleMessages);
|
||||
addResourceHandler("send_message", this, &ChatHandler::handleSendMessage);
|
||||
addResourceHandler("mark_message_as_read", this, &ChatHandler::handleMarkMessageAsRead);
|
||||
@ -1034,6 +1038,82 @@ ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
|
||||
return new SendLobbyParticipantsTask(mRsIdentity, mit->second);
|
||||
}
|
||||
|
||||
void ChatHandler::handleGetDefaultIdentityForChatLobby(Request& req, Response& resp)
|
||||
{
|
||||
RsGxsId gxsId;
|
||||
mRsMsgs->getDefaultIdentityForChatLobby(gxsId);
|
||||
resp.mDataStream << makeKeyValue("gxs_id", gxsId.toStdString());
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void ChatHandler::handleSetDefaultIdentityForChatLobby(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
RsGxsId gxsId(gxs_id);
|
||||
|
||||
if(gxsId.isNull())
|
||||
{
|
||||
resp.setFail("Error: gxs_id must not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
if(mRsMsgs->setDefaultIdentityForChatLobby(gxsId))
|
||||
resp.setOk();
|
||||
else
|
||||
resp.setFail("Failure to change default identity for chat lobby");
|
||||
}
|
||||
|
||||
void ChatHandler::handleGetIdentityForChatLobby(Request& req, Response& resp)
|
||||
{
|
||||
RsGxsId gxsId;
|
||||
std::string chat_id;
|
||||
req.mStream << makeKeyValueReference("chat_id", chat_id);
|
||||
ChatId chatId(chat_id);
|
||||
|
||||
if(chatId.isNotSet())
|
||||
{
|
||||
resp.setFail("Error: chat_id must not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
if(mRsMsgs->getIdentityForChatLobby(chatId.toLobbyId(), gxsId))
|
||||
{
|
||||
resp.mDataStream << makeKeyValue("gxs_id", gxsId.toStdString());
|
||||
resp.setOk();
|
||||
}
|
||||
else
|
||||
resp.setFail();
|
||||
}
|
||||
|
||||
void ChatHandler::handleSetIdentityForChatLobby(Request& req, Response& resp)
|
||||
{
|
||||
std::string chat_id;
|
||||
req.mStream << makeKeyValueReference("chat_id", chat_id);
|
||||
ChatId chatId(chat_id);
|
||||
|
||||
if(chatId.isNotSet())
|
||||
{
|
||||
resp.setFail("Error: chat_id must not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
RsGxsId gxsId(gxs_id);
|
||||
|
||||
if(gxsId.isNull())
|
||||
{
|
||||
resp.setFail("Error: gxs_id must not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
if(mRsMsgs->setIdentityForChatLobby(chatId.toLobbyId(), gxsId))
|
||||
resp.setOk();
|
||||
else
|
||||
resp.setFail();
|
||||
}
|
||||
|
||||
void ChatHandler::handleMessages(Request &req, Response &resp)
|
||||
{
|
||||
/* G10h4ck: Whithout this the request processing won't happen, copied from
|
||||
|
@ -129,6 +129,10 @@ private:
|
||||
void handleAnswerToInvitation(Request& req, Response& resp);
|
||||
void handleClearLobby(Request& req, Response& resp);
|
||||
ResponseTask* handleLobbyParticipants(Request& req, Response& resp);
|
||||
void handleGetDefaultIdentityForChatLobby(Request& req, Response& resp);
|
||||
void handleSetDefaultIdentityForChatLobby(Request& req, Response& resp);
|
||||
void handleGetIdentityForChatLobby(Request& req, Response& resp);
|
||||
void handleSetIdentityForChatLobby(Request& req, Response& resp);
|
||||
void handleMessages(Request& req, Response& resp);
|
||||
void handleSendMessage(Request& req, Response& resp);
|
||||
void handleMarkMessageAsRead(Request& req, Response& resp);
|
||||
|
Loading…
Reference in New Issue
Block a user