added a flag for moderating messages to help removign them when the author is not a moderator anymore

This commit is contained in:
csoler 2018-09-02 17:07:40 +02:00
parent e7d721b3de
commit 59535eac8a
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
9 changed files with 29 additions and 12 deletions

View File

@ -111,7 +111,7 @@ public:
RsTlvKeySignatureSet signSet; RsTlvKeySignatureSet signSet;
std::string mMsgName; std::string mMsgName;
time_t mPublishTs; time_t mPublishTs;
uint32_t mMsgFlags; // Whats this for? uint32_t mMsgFlags; // used by some services (e.g. by forums to store message moderation flags)
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG. // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// normally READ / UNREAD flags. LOCAL Data. // normally READ / UNREAD flags. LOCAL Data.

View File

@ -115,8 +115,7 @@ namespace GXS_SERV {
/** START GXS Grp status flags **/ /** START GXS Grp status flags **/
static const uint32_t GXS_GRP_STATUS_UNPROCESSED = 0x000000100; static const uint32_t GXS_GRP_STATUS_UNPROCESSED = 0x000000100;
static const uint32_t GXS_GRP_STATUS_UNREAD = 0x000000200;
static const uint32_t GXS_GRP_STATUS_UNREAD = 0x00000200;
/** END GXS Grp status flags **/ /** END GXS Grp status flags **/
} }

View File

@ -30,6 +30,14 @@
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
#include "serialiser/rstlvidset.h" #include "serialiser/rstlvidset.h"
// Forum Service message flags, to be used in RsMsgMetaData::mMsgFlags
// Gxs imposes to use the first two bytes (lower bytes) of mMsgFlags for private forum flags, the upper bytes being used for internal GXS stuff.
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MASK = 0x0000000f ;
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001 ;
#define IS_FORUM_MSG_MODERATION(flags) (flags & RS_GXS_FORUM_MSG_FLAGS_MODERATED)
/* The Main Interface Class - for information about your Peers */ /* The Main Interface Class - for information about your Peers */
class RsGxsForums; class RsGxsForums;
extern RsGxsForums *rsGxsForums; extern RsGxsForums *rsGxsForums;

View File

@ -138,7 +138,7 @@ struct RsMsgMetaData : RsSerializable
std::string mMsgName; std::string mMsgName;
time_t mPublishTs; time_t mPublishTs;
/// the first 16 bits for service, last 16 for GXS /// the lower 16 bits for service, upper 16 bits for GXS
uint32_t mMsgFlags; uint32_t mMsgFlags;
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG. // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.

View File

@ -50,8 +50,9 @@
//#define ENABLE_GENERATE //#define ENABLE_GENERATE
/** Constructor */ /** Constructor */
CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId,const RsGxsMessageId& mOId,const RsGxsId& posterId) CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId& mOId, const RsGxsId& posterId, bool isModerating)
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId), mOrigMsgId(mOId),mPosterId(posterId) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
mForumId(fId), mParentId(pId), mOrigMsgId(mOId),mPosterId(posterId),mIsModerating(isModerating)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -355,7 +356,9 @@ void CreateGxsForumMsg::createMsg()
msg.mMeta.mGroupId = mForumId; msg.mMeta.mGroupId = mForumId;
msg.mMeta.mParentId = mParentId; msg.mMeta.mParentId = mParentId;
msg.mMeta.mOrigMsgId = mOrigMsgId; msg.mMeta.mOrigMsgId = mOrigMsgId;
msg.mMeta.mMsgFlags = mIsModerating?RS_GXS_FORUM_MSG_FLAGS_MODERATED : 0;
msg.mMeta.mMsgId.clear() ; msg.mMeta.mMsgId.clear() ;
if (mParentMsgLoaded) { if (mParentMsgLoaded) {
msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId; msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId;
}//if (mParentMsgLoaded) }//if (mParentMsgLoaded)

View File

@ -36,7 +36,7 @@ class CreateGxsForumMsg : public QDialog, public TokenResponse
Q_OBJECT Q_OBJECT
public: public:
CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId &moId, const RsGxsId &posterId = RsGxsId()); CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId &moId, const RsGxsId &posterId = RsGxsId(),bool isModerating=false);
~CreateGxsForumMsg(); ~CreateGxsForumMsg();
void newMsg(); /* cleanup */ void newMsg(); /* cleanup */
@ -75,6 +75,7 @@ private:
bool mOrigMsgLoaded; bool mOrigMsgLoaded;
bool mForumMetaLoaded; bool mForumMetaLoaded;
bool mForumCircleLoaded ; bool mForumCircleLoaded ;
bool mIsModerating; // means that the msg has a orig author Id that is not the Id of the author
RsGxsForumMsg mParentMsg; RsGxsForumMsg mParentMsg;
RsGxsForumMsg mOrigMsg; RsGxsForumMsg mOrigMsg;

View File

@ -2325,7 +2325,7 @@ void GxsForumThreadWidget::editForumMessageData(const RsGxsForumMsg& msg)
if (!msg.mMeta.mAuthorId.isNull()) if (!msg.mMeta.mAuthorId.isNull())
{ {
CreateGxsForumMsg *cfm = new CreateGxsForumMsg(groupId(), msg.mMeta.mParentId, msg.mMeta.mMsgId, is_own?(msg.mMeta.mAuthorId):moderator_id); CreateGxsForumMsg *cfm = new CreateGxsForumMsg(groupId(), msg.mMeta.mParentId, msg.mMeta.mMsgId, is_own?(msg.mMeta.mAuthorId):moderator_id,!is_own);
cfm->insertPastedText(QString::fromUtf8(msg.mMsg.c_str())) ; cfm->insertPastedText(QString::fromUtf8(msg.mMsg.c_str())) ;
cfm->show(); cfm->show();

View File

@ -255,9 +255,15 @@ void GxsForumsFillThread::run()
// Make sure that the author is the same than the original message, or is a moderator. This should always happen when messages are constructed using // Make sure that the author is the same than the original message, or is a moderator. This should always happen when messages are constructed using
// the UI but nothing can prevent a nasty user to craft a new version of a message with his own signature. // the UI but nothing can prevent a nasty user to craft a new version of a message with his own signature.
if(msgIt2->second.mMeta.mAuthorId != msgIt->second.mMeta.mAuthorId && forum_group.mAdminList.ids.find(msgIt->second.mMeta.mAuthorId)==forum_group.mAdminList.ids.end()) if(msgIt2->second.mMeta.mAuthorId != msgIt->second.mMeta.mAuthorId)
{
if( !IS_FORUM_MSG_MODERATION(msgIt->second.mMeta.mMsgFlags) ) // if authors are different the moderation flag needs to be set on the editing msg
continue ; continue ;
if( forum_group.mAdminList.ids.find(msgIt->second.mMeta.mAuthorId)==forum_group.mAdminList.ids.end()) // if author is not a moderator, continue
continue ;
}
// always add the post a self version // always add the post a self version
if(mPostVersions[msgIt->second.mMeta.mOrigMsgId].empty()) if(mPostVersions[msgIt->second.mMeta.mOrigMsgId].empty())