mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1604 from G10h4ck/forum_api_refinement
Workaround JSON API opacity of RsTlv*Set in RsGxsForumGroup
This commit is contained in:
commit
e5fab995d6
@ -59,25 +59,17 @@ struct RsGxsForumGroup : RsSerializable
|
|||||||
RsGroupMetaData mMeta;
|
RsGroupMetaData mMeta;
|
||||||
std::string mDescription;
|
std::string mDescription;
|
||||||
|
|
||||||
/* What's below is optional, and handled by the serialiser
|
/* TODO: run away from TLV old serializables as those types are opaque to
|
||||||
* TODO: run away from TLV old serializables as those types are opaque to
|
* JSON API! */
|
||||||
* JSON API! */
|
|
||||||
RsTlvGxsIdSet mAdminList;
|
RsTlvGxsIdSet mAdminList;
|
||||||
RsTlvGxsMsgIdSet mPinnedPosts;
|
RsTlvGxsMsgIdSet mPinnedPosts;
|
||||||
|
|
||||||
/// @see RsSerializable
|
/// @see RsSerializable
|
||||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
RsGenericSerializer::SerializeContext& ctx )
|
RsGenericSerializer::SerializeContext& ctx );
|
||||||
{
|
|
||||||
RS_SERIAL_PROCESS(mMeta);
|
|
||||||
RS_SERIAL_PROCESS(mDescription);
|
|
||||||
RS_SERIAL_PROCESS(mAdminList);
|
|
||||||
RS_SERIAL_PROCESS(mPinnedPosts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// utility functions
|
/// utility functions
|
||||||
|
bool canEditPosts(const RsGxsId& id) const;
|
||||||
bool canEditPosts(const RsGxsId& id) const { return mAdminList.ids.find(id) != mAdminList.ids.end() || id == mMeta.mAuthorId; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsForumMsg : RsSerializable
|
struct RsGxsForumMsg : RsSerializable
|
||||||
@ -203,4 +195,3 @@ public:
|
|||||||
RS_DEPRECATED_FOR(editForum)
|
RS_DEPRECATED_FOR(editForum)
|
||||||
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
|
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -813,3 +813,34 @@ void p3GxsForums::handle_event(uint32_t event_type, const std::string &/*elabel*
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsGxsForumGroup::serial_process(
|
||||||
|
RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx )
|
||||||
|
{
|
||||||
|
RS_SERIAL_PROCESS(mMeta);
|
||||||
|
RS_SERIAL_PROCESS(mDescription);
|
||||||
|
|
||||||
|
/* Work around to have usable JSON API, without breaking binary
|
||||||
|
* serialization retrocompatibility */
|
||||||
|
switch (j)
|
||||||
|
{
|
||||||
|
case RsGenericSerializer::TO_JSON: // fallthrough
|
||||||
|
case RsGenericSerializer::FROM_JSON:
|
||||||
|
RsTypeSerializer::serial_process( j, ctx,
|
||||||
|
mAdminList.ids, "mAdminList" );
|
||||||
|
RsTypeSerializer::serial_process( j, ctx,
|
||||||
|
mPinnedPosts.ids, "mPinnedPosts" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RS_SERIAL_PROCESS(mAdminList);
|
||||||
|
RS_SERIAL_PROCESS(mPinnedPosts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RsGxsForumGroup::canEditPosts(const RsGxsId& id) const
|
||||||
|
{
|
||||||
|
return mAdminList.ids.find(id) != mAdminList.ids.end() ||
|
||||||
|
id == mMeta.mAuthorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user