added NEW_COMMENT and NEW_VOTE to rsEvents types in Posted and Channels

This commit is contained in:
csoler 2020-11-07 16:55:15 +01:00
parent dc90d6f6dc
commit 3cac0c030d
4 changed files with 25 additions and 4 deletions

View File

@ -116,6 +116,8 @@ enum class RsChannelEventCode: uint8_t
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
SYNC_PARAMETERS_UPDATED = 0x0a, // sync and storage times have changed SYNC_PARAMETERS_UPDATED = 0x0a, // sync and storage times have changed
NEW_COMMENT = 0x0b, // new comment arrived/published. mChannelThreadId gives the ID of the commented message
NEW_VOTE = 0x0c, // new vote arrived/published. mChannelThreadId gives the ID of the votes message comment
}; };
struct RsGxsChannelEvent: RsEvent struct RsGxsChannelEvent: RsEvent
@ -125,6 +127,7 @@ struct RsGxsChannelEvent: RsEvent
RsChannelEventCode mChannelEventCode; RsChannelEventCode mChannelEventCode;
RsGxsGroupId mChannelGroupId; RsGxsGroupId mChannelGroupId;
RsGxsMessageId mChannelMsgId; RsGxsMessageId mChannelMsgId;
RsGxsMessageId mChannelThreadId;
///* @see RsEvent @see RsSerializable ///* @see RsEvent @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override

View File

@ -117,6 +117,8 @@ enum class RsPostedEventCode: uint8_t
STATISTICS_CHANGED = 0x07, STATISTICS_CHANGED = 0x07,
MESSAGE_VOTES_UPDATED = 0x08, MESSAGE_VOTES_UPDATED = 0x08,
SYNC_PARAMETERS_UPDATED = 0x09, SYNC_PARAMETERS_UPDATED = 0x09,
NEW_COMMENT = 0x0a,
NEW_VOTE = 0x0b,
}; };

View File

@ -259,7 +259,15 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mChannelMsgId = msgChange->mMsgId; ev->mChannelMsgId = msgChange->mMsgId;
ev->mChannelGroupId = msgChange->mGroupId; ev->mChannelGroupId = msgChange->mGroupId;
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
if(nullptr != dynamic_cast<RsGxsCommentItem*>(msgChange->mNewMsgItem))
ev->mChannelEventCode = RsChannelEventCode::NEW_COMMENT;
else
if(nullptr != dynamic_cast<RsGxsVoteItem*>(msgChange->mNewMsgItem))
ev->mChannelEventCode = RsChannelEventCode::NEW_VOTE;
else
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
} }
} }

View File

@ -107,10 +107,18 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
case RsGxsNotify::TYPE_PUBLISHED: case RsGxsNotify::TYPE_PUBLISHED:
{ {
auto ev = std::make_shared<RsGxsPostedEvent>(); auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedMsgId = msgChange->mMsgId; ev->mPostedMsgId = msgChange->mMsgId;
ev->mPostedThreadId = msgChange->mNewMsgItem->meta.mThreadId; ev->mPostedThreadId = msgChange->mNewMsgItem->meta.mThreadId;
ev->mPostedGroupId = msgChange->mGroupId; ev->mPostedGroupId = msgChange->mGroupId;
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
if(nullptr != dynamic_cast<RsGxsCommentItem*>(msgChange->mNewMsgItem))
ev->mPostedEventCode = RsPostedEventCode::NEW_COMMENT;
else
if(nullptr != dynamic_cast<RsGxsVoteItem*>(msgChange->mNewMsgItem))
ev->mPostedEventCode = RsPostedEventCode::NEW_VOTE;
else
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
#ifdef POSTBASE_DEBUG #ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: NEW/PUBLISHED ID=" << msgChange->mMsgId << " in group " << msgChange->mGroupId << ", thread ID = " << msgChange->mNewMsgItem->meta.mThreadId << std::endl; std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: NEW/PUBLISHED ID=" << msgChange->mMsgId << " in group " << msgChange->mGroupId << ", thread ID = " << msgChange->mNewMsgItem->meta.mThreadId << std::endl;