mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-09-22 22:04:53 -04:00
Merge 59db1e21a5
into 8ebd9ba21f
This commit is contained in:
commit
0abed242dd
3 changed files with 32 additions and 43 deletions
|
@ -52,9 +52,9 @@
|
||||||
//#define ENABLE_GENERATE
|
//#define ENABLE_GENERATE
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId& mOId, const RsGxsId& posterId, bool isModerating)
|
CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId& mOId, const RsGxsId& posterId, const std::set<RsGxsId>& moderatorSet)
|
||||||
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||||
mForumId(fId), mParentId(pId), mOrigMsgId(mOId),mPosterId(posterId),mIsModerating(isModerating),
|
mForumId(fId), mParentId(pId), mOrigMsgId(mOId), mPosterId(posterId), mModeratorSet(moderatorSet),
|
||||||
ui(new Ui::CreateGxsForumMsg)
|
ui(new Ui::CreateGxsForumMsg)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
|
@ -85,7 +85,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||||
|
|
||||||
QString text = mOId.isNull()?(pId.isNull() ? tr("Start New Thread") : tr("Post Forum Message")):tr("Edit Message");
|
QString text = mOId.isNull()?(pId.isNull() ? tr("Start New Thread") : tr("Post Forum Message")):tr("Edit Message");
|
||||||
setWindowTitle(text);
|
setWindowTitle(text);
|
||||||
|
|
||||||
if (!mOId.isNull())
|
if (!mOId.isNull())
|
||||||
ui->postButton->setText(tr ("Update"));
|
ui->postButton->setText(tr ("Update"));
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||||
mForumCircleLoaded = false;
|
mForumCircleLoaded = false;
|
||||||
|
|
||||||
newMsg();
|
newMsg();
|
||||||
|
|
||||||
ui->hashGroupBox->hide();
|
ui->hashGroupBox->hide();
|
||||||
|
|
||||||
#ifndef ENABLE_GENERATE
|
#ifndef ENABLE_GENERATE
|
||||||
|
@ -167,21 +167,24 @@ void CreateGxsForumMsg::newMsg()
|
||||||
mForumMetaLoaded = false;
|
mForumMetaLoaded = false;
|
||||||
|
|
||||||
/* fill in the available OwnIds for signing */
|
/* fill in the available OwnIds for signing */
|
||||||
|
|
||||||
//std::cerr << "Initing ID chooser. Sign flags = " << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
|
|
||||||
|
|
||||||
if(!mPosterId.isNull())
|
|
||||||
{
|
|
||||||
std::set<RsGxsId> id_set ;
|
|
||||||
id_set.insert(mPosterId) ;
|
|
||||||
|
|
||||||
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NO_CREATE, mPosterId);
|
//std::cerr << "Initing ID chooser. Sign flags = " << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
|
||||||
|
uint32_t idChooserFlags = IDCHOOSER_ID_REQUIRED;
|
||||||
|
if(!mOrigMsgId.isNull()) {
|
||||||
|
// we are editing an existing message
|
||||||
|
std::set<RsGxsId> id_set = mModeratorSet;
|
||||||
|
if(!mPosterId.isNull())
|
||||||
|
id_set.insert(mPosterId);
|
||||||
|
|
||||||
|
// TODO: Report error if idChooser has no IDs to choose from.
|
||||||
|
// NOTE: mPosterId may not be our own; then GxsIdChooser will not include it.
|
||||||
|
|
||||||
|
idChooserFlags |= IDCHOOSER_NO_CREATE;
|
||||||
ui->idChooser->setIdConstraintSet(id_set);
|
ui->idChooser->setIdConstraintSet(id_set);
|
||||||
}
|
}
|
||||||
else
|
ui->idChooser->loadIds(idChooserFlags, mPosterId);
|
||||||
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, mPosterId);
|
|
||||||
|
|
||||||
if (mForumId.isNull()) {
|
if (mForumId.isNull()) {
|
||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||||
|
@ -403,7 +406,7 @@ 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.mMsgFlags = 0;
|
||||||
msg.mMeta.mMsgId.clear() ;
|
msg.mMeta.mMsgId.clear() ;
|
||||||
|
|
||||||
if (mParentMsgLoaded) {
|
if (mParentMsgLoaded) {
|
||||||
|
@ -425,6 +428,8 @@ void CreateGxsForumMsg::createMsg()
|
||||||
case GxsIdChooser::KnowId:
|
case GxsIdChooser::KnowId:
|
||||||
case GxsIdChooser::UnKnowId:
|
case GxsIdChooser::UnKnowId:
|
||||||
msg.mMeta.mAuthorId = authorId;
|
msg.mMeta.mAuthorId = authorId;
|
||||||
|
if(!mOrigMsgId.isNull() && authorId != mPosterId)
|
||||||
|
msg.mMeta.mMsgFlags |= RS_GXS_FORUM_MSG_FLAGS_MODERATED;
|
||||||
//std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
|
//std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
|
||||||
//std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
|
|
||||||
|
@ -577,7 +582,7 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||||
void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id)
|
void CreateGxsForumMsg::loadCircleInfo(const RsGxsGroupId& circle_id)
|
||||||
{
|
{
|
||||||
//std::cerr << "Loading forum circle info" << std::endl;
|
//std::cerr << "Loading forum circle info" << std::endl;
|
||||||
|
|
||||||
RsThread::async( [circle_id,this]()
|
RsThread::async( [circle_id,this]()
|
||||||
{
|
{
|
||||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CreateGxsForumMsg : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId &moId, const RsGxsId &posterId = RsGxsId(),bool isModerating=false);
|
CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId &moId, const RsGxsId &posterId = RsGxsId(), const std::set<RsGxsId>& moderatorSet = std::set<RsGxsId>());
|
||||||
~CreateGxsForumMsg();
|
~CreateGxsForumMsg();
|
||||||
|
|
||||||
void newMsg(); /* cleanup */
|
void newMsg(); /* cleanup */
|
||||||
|
@ -59,7 +59,7 @@ private slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
|
|
||||||
void loadCircleInfo(const RsGxsGroupId& circle_id);
|
void loadCircleInfo(const RsGxsGroupId& circle_id);
|
||||||
private:
|
private:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
|
@ -75,7 +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
|
std::set<RsGxsId> mModeratorSet; // these IDs are allowed to edit the post in addition to mPosterId
|
||||||
|
|
||||||
RsGxsForumMsg mParentMsg;
|
RsGxsForumMsg mParentMsg;
|
||||||
RsGxsForumMsg mOrigMsg;
|
RsGxsForumMsg mOrigMsg;
|
||||||
|
|
|
@ -1753,33 +1753,17 @@ void GxsForumThreadWidget::editForumMessageData(const RsGxsForumMsg& msg)
|
||||||
|
|
||||||
std::list<RsGxsId> own_ids ;
|
std::list<RsGxsId> own_ids ;
|
||||||
rsIdentity->getOwnIds(own_ids) ;
|
rsIdentity->getOwnIds(own_ids) ;
|
||||||
|
std::set<RsGxsId> modIds;
|
||||||
for(auto it(own_ids.begin());it!=own_ids.end();++it)
|
for(auto it(own_ids.begin());it!=own_ids.end();++it)
|
||||||
if(mForumGroup.mAdminList.ids.find(*it) != mForumGroup.mAdminList.ids.end())
|
if(mForumGroup.mAdminList.ids.find(*it) != mForumGroup.mAdminList.ids.end())
|
||||||
{
|
modIds.insert(*it);
|
||||||
moderator_id = *it;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that author is in own ids, if not use the moderator id that was collected among own ids.
|
CreateGxsForumMsg *cfm = new CreateGxsForumMsg(groupId(), msg.mMeta.mParentId, msg.mMeta.mMsgId, msg.mMeta.mAuthorId, modIds);
|
||||||
bool is_own = false ;
|
|
||||||
for(auto it(own_ids.begin());it!=own_ids.end() && !is_own;++it)
|
|
||||||
if(*it == msg.mMeta.mAuthorId)
|
|
||||||
is_own = true ;
|
|
||||||
|
|
||||||
if (!msg.mMeta.mAuthorId.isNull())
|
cfm->insertPastedText(QString::fromUtf8(msg.mMsg.c_str())) ;
|
||||||
{
|
cfm->show();
|
||||||
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 window will destroy itself! */
|
||||||
cfm->show();
|
|
||||||
|
|
||||||
/* window will destroy itself! */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to an Anonymous Author"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void GxsForumThreadWidget::replyForumMessageData(const RsGxsForumMsg &msg)
|
void GxsForumThreadWidget::replyForumMessageData(const RsGxsForumMsg &msg)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue