mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 23:25:32 -04:00
Fixup how REF message are displayed
Ensure RefImageCount is correct. Update docs on m(Ref)GroupPtr points to fill-in GroupPtrs on Ref Msgs. Remove mRefAuthorName as not so useful. Add images into Response Msgs. Display Headshot / Images on Ref Msgs - if possible.
This commit is contained in:
parent
fbf56fcf03
commit
f4457b1331
7 changed files with 113 additions and 21 deletions
|
@ -152,10 +152,9 @@ class RsWirePulse
|
|||
std::string mRefGroupName; // PARENT_GrpName REPLY_GrpName
|
||||
RsGxsMessageId mRefOrigMsgId; // PARENT_OrigMsgId REPLY_OrigMsgId
|
||||
RsGxsId mRefAuthorId; // PARENT_AuthorId REPLY_AuthorId
|
||||
std::string mRefAuthorName; // PARENT_AuthorName REPLY_AuthorName // TODO
|
||||
rstime_t mRefPublishTs; // PARENT_PublishTs REPLY_PublishTs
|
||||
std::string mRefPulseText; // PARENT_PulseText REPLY_PulseText
|
||||
uint32_t mRefImageCount; // PARENT_#Images REPLY_#Images // TODO
|
||||
uint32_t mRefImageCount; // PARENT_#Images REPLY_#Images
|
||||
|
||||
// Additional Fields for version 2.
|
||||
// Images, need to enforce 20k limit?
|
||||
|
@ -167,12 +166,16 @@ class RsWirePulse
|
|||
// Below Here is not serialised.
|
||||
// They are additional fields linking pulses together or parsing elements of msg.
|
||||
|
||||
// functions.
|
||||
uint32_t ImageCount();
|
||||
|
||||
// can't have self referencial list, so need to use pointers.
|
||||
// using SharedPointers to automatically cleanup.
|
||||
|
||||
// Pointer to WireGroup.
|
||||
RsWireGroupSPtr mRefGroupPtr;
|
||||
RsWireGroupSPtr mGroupPtr;
|
||||
// Pointer to WireGroups
|
||||
// mRefGroupPtr is opportunistically filled in, but will often be empty.
|
||||
RsWireGroupSPtr mRefGroupPtr; // ORIG/RESP: N/A , REF: Reply Group
|
||||
RsWireGroupSPtr mGroupPtr; // ORIG/RESP: Own Group, REF: Parent Group
|
||||
|
||||
// These are the direct children of this message
|
||||
// split into likes, replies and retweets.
|
||||
|
|
|
@ -66,7 +66,6 @@ void RsGxsWirePulseItem::clear()
|
|||
pulse.mRefGroupName.clear();
|
||||
pulse.mRefOrigMsgId.clear();
|
||||
pulse.mRefAuthorId.clear();
|
||||
pulse.mRefAuthorName.clear();
|
||||
pulse.mRefPublishTs = 0;
|
||||
pulse.mRefPulseText.clear();
|
||||
pulse.mRefImageCount = 0;
|
||||
|
@ -86,7 +85,6 @@ void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
|
|||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefAuthorId,"pulse.mRefAuthorId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefAuthorName,"pulse.mRefAuthorName") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefPublishTs,"pulse.mRefPublishTs") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mRefPulseText,"pulse.mRefPulseText") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mRefImageCount,"pulse.mRefImageCount") ;
|
||||
|
|
|
@ -31,6 +31,23 @@
|
|||
RsWire *rsWire = NULL;
|
||||
|
||||
|
||||
uint32_t RsWirePulse::ImageCount()
|
||||
{
|
||||
if (!mImage4.empty()) {
|
||||
return 4;
|
||||
}
|
||||
if (!mImage3.empty()) {
|
||||
return 3;
|
||||
}
|
||||
if (!mImage2.empty()) {
|
||||
return 2;
|
||||
}
|
||||
if (!mImage1.empty()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
p3Wire::p3Wire(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs)
|
||||
:RsGenExchange(gds, nes, new RsGxsWireSerialiser(), RS_SERVICE_GXS_TYPE_WIRE, gixs, wireAuthenPolicy()),
|
||||
RsWire(static_cast<RsGxsIface&>(*this)), mWireMtx("WireMtx")
|
||||
|
@ -629,6 +646,10 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
|||
responsePulse.mPulseType = WIRE_PULSE_TYPE_RESPONSE | reply_type;
|
||||
responsePulse.mSentiment = pPulse->mSentiment;
|
||||
responsePulse.mPulseText = pPulse->mPulseText;
|
||||
responsePulse.mImage1 = pPulse->mImage1;
|
||||
responsePulse.mImage2 = pPulse->mImage2;
|
||||
responsePulse.mImage3 = pPulse->mImage3;
|
||||
responsePulse.mImage4 = pPulse->mImage4;
|
||||
|
||||
// mRefs refer to parent post.
|
||||
responsePulse.mRefGroupId = replyToPulse->mMeta.mGroupId;
|
||||
|
@ -637,6 +658,7 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
|||
responsePulse.mRefAuthorId = replyToPulse->mMeta.mAuthorId;
|
||||
responsePulse.mRefPublishTs = replyToPulse->mMeta.mPublishTs;
|
||||
responsePulse.mRefPulseText = replyToPulse->mPulseText;
|
||||
responsePulse.mRefImageCount = replyToPulse->ImageCount();
|
||||
|
||||
std::cerr << "p3Wire::createReplyPulse() create Response Pulse";
|
||||
std::cerr << std::endl;
|
||||
|
@ -720,6 +742,7 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
|||
refPulse.mRefAuthorId = replyWithGroup.mMeta.mAuthorId;
|
||||
refPulse.mRefPublishTs = createdResponsePulse->mMeta.mPublishTs;
|
||||
refPulse.mRefPulseText = createdResponsePulse->mPulseText;
|
||||
refPulse.mRefImageCount = createdResponsePulse->ImageCount();
|
||||
|
||||
// publish Ref Msg.
|
||||
if (!createPulse(token, refPulse))
|
||||
|
@ -1181,13 +1204,6 @@ bool p3Wire::extractGroupIds(RsWirePulseConstSPtr pPulse, std::set<RsGxsGroupId>
|
|||
|
||||
bool p3Wire::updateGroupPtrs(RsWirePulseSPtr pPulse, const std::map<RsGxsGroupId, RsWireGroupSPtr> &groups)
|
||||
{
|
||||
/* don't bother with Refs... though we could */
|
||||
/* do this recursively */
|
||||
if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) {
|
||||
/* skipping */
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, RsWireGroupSPtr>::const_iterator git;
|
||||
git = groups.find(pPulse->mMeta.mGroupId);
|
||||
if (git == groups.end()) {
|
||||
|
@ -1197,6 +1213,23 @@ bool p3Wire::updateGroupPtrs(RsWirePulseSPtr pPulse, const std::map<RsGxsGroupId
|
|||
|
||||
pPulse->mGroupPtr = git->second;
|
||||
|
||||
/* if Refs, GroupId refers to parent, so GroupPtr is parent's group
|
||||
* It should already be in groups lists - if its not... */
|
||||
if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) {
|
||||
// if REF is in list, fill in (unlikely but try anyway)
|
||||
// unlikely, as we are not adding RefGroupId, as can potentially fail to look up.
|
||||
// need additional flag OKAY_IF_NONEXISTENT or similar.
|
||||
// no error if its not there.
|
||||
std::map<RsGxsGroupId, RsWireGroupSPtr>::const_iterator rgit;
|
||||
rgit = groups.find(pPulse->mRefGroupId);
|
||||
if (rgit != groups.end()) {
|
||||
pPulse->mRefGroupPtr = rgit->second;
|
||||
}
|
||||
|
||||
// no children for REF pulse, so can return now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/* recursively apply to children */
|
||||
std::list<RsWirePulseSPtr>::iterator it;
|
||||
for (it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue