mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
gxschannel expose blocking create post and channels API
This commit is contained in:
parent
184fac95ae
commit
321d2e84bd
@ -137,6 +137,23 @@ public:
|
|||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) = 0;
|
std::vector<RsGxsComment>& comments ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create channel. Blocking API.
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[inout] channel Channel data (name, description...)
|
||||||
|
* @return false on error, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool createChannel(RsGxsChannelGroup& channel) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create channel post. Blocking API.
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[inout] post
|
||||||
|
* @return false on error, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool createPost(RsGxsChannelPost& post) = 0;
|
||||||
|
|
||||||
|
|
||||||
/* Specific Service Data
|
/* Specific Service Data
|
||||||
* TODO: change the orrible const uint32_t &token to uint32_t token
|
* TODO: change the orrible const uint32_t &token to uint32_t token
|
||||||
* TODO: create a new typedef for token so code is easier to read
|
* TODO: create a new typedef for token so code is easier to read
|
||||||
@ -225,7 +242,6 @@ public:
|
|||||||
* @brief Request channel creation.
|
* @brief Request channel creation.
|
||||||
* The action is performed asyncronously, so it could fail in a subsequent
|
* The action is performed asyncronously, so it could fail in a subsequent
|
||||||
* phase even after returning true.
|
* phase even after returning true.
|
||||||
* @jsonapi{development}
|
|
||||||
* @param[out] token Storage for RsTokenService token to track request
|
* @param[out] token Storage for RsTokenService token to track request
|
||||||
* status.
|
* status.
|
||||||
* @param[in] group Channel data (name, description...)
|
* @param[in] group Channel data (name, description...)
|
||||||
@ -237,7 +253,6 @@ public:
|
|||||||
* @brief Request post creation.
|
* @brief Request post creation.
|
||||||
* The action is performed asyncronously, so it could fail in a subsequent
|
* The action is performed asyncronously, so it could fail in a subsequent
|
||||||
* phase even after returning true.
|
* phase even after returning true.
|
||||||
* @jsonapi{development}
|
|
||||||
* @param[out] token Storage for RsTokenService token to track request
|
* @param[out] token Storage for RsTokenService token to track request
|
||||||
* status.
|
* status.
|
||||||
* @param[in] post
|
* @param[in] post
|
||||||
|
@ -34,17 +34,22 @@
|
|||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
#include "retroshare/rsnotify.h"
|
#include "retroshare/rsnotify.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
// For Dummy Msgs.
|
// For Dummy Msgs.
|
||||||
#include "util/rsrandom.h"
|
#include "util/rsrandom.h"
|
||||||
#include "util/rsstring.h"
|
#include "util/rsstring.h"
|
||||||
|
|
||||||
|
#ifdef RS_DEEP_SEARCH
|
||||||
|
# include "deep_search/deep_search.h"
|
||||||
|
#endif // RS_DEEP_SEARCH
|
||||||
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define GXSCHANNEL_DEBUG 1
|
* #define GXSCHANNEL_DEBUG 1
|
||||||
****/
|
****/
|
||||||
|
|
||||||
RsGxsChannels *rsGxsChannels = NULL;
|
/*extern*/ RsGxsChannels *rsGxsChannels = nullptr;
|
||||||
|
|
||||||
|
|
||||||
#define GXSCHANNEL_STOREPERIOD (3600 * 24 * 30)
|
#define GXSCHANNEL_STOREPERIOD (3600 * 24 * 30)
|
||||||
@ -1036,6 +1041,35 @@ bool p3GxsChannels::getChannelsContent(
|
|||||||
return getPostData(token, posts, comments);
|
return getPostData(token, posts, comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel)
|
||||||
|
{
|
||||||
|
uint32_t token;
|
||||||
|
if( !createGroup(token, channel)
|
||||||
|
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||||
|
|
||||||
|
// TODO: Need a way to get the channel id back!
|
||||||
|
//#ifdef RS_DEEP_SEARCH
|
||||||
|
// DeepSearch::indexChannelGroup(channel);
|
||||||
|
//#endif // RS_DEEP_SEARCH
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3GxsChannels::createPost(RsGxsChannelPost& post)
|
||||||
|
{
|
||||||
|
uint32_t token;
|
||||||
|
if( !createPost(token, post)
|
||||||
|
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||||
|
|
||||||
|
// TODO: Need a way to get the post id back!
|
||||||
|
//#ifdef RS_DEEP_SEARCH
|
||||||
|
// DeepSearch::indexChannelPost(post);
|
||||||
|
//#endif // RS_DEEP_SEARCH
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Blocking API implementation end
|
/// Blocking API implementation end
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -182,6 +182,12 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
|||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments );
|
std::vector<RsGxsComment>& comments );
|
||||||
|
|
||||||
|
/// Implementation of @see RsGxsChannels::createChannel
|
||||||
|
virtual bool createChannel(RsGxsChannelGroup& channel);
|
||||||
|
|
||||||
|
/// Implementation of @see RsGxsChannels::createPost
|
||||||
|
virtual bool createPost(RsGxsChannelPost& post);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overloaded from GxsTokenQueue for Request callbacks.
|
// Overloaded from GxsTokenQueue for Request callbacks.
|
||||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||||
|
Loading…
Reference in New Issue
Block a user