Provide usable API to send RS mails

Return trackid to sendmail caller
Post RsEvents when sent mail change status
Deprecate old MessageSend
This commit is contained in:
Gioacchino Mazzurco 2019-09-16 18:40:07 +02:00
parent 584918388c
commit 04d3325fbd
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
6 changed files with 368 additions and 90 deletions

View File

@ -66,6 +66,9 @@ enum class RsEventType : uint32_t
/// Emitted when a peer state changes, @see RsPeers
PEER_STATE_CHANGED = 6,
/// @see RsMailStatusEvent
MAIL_STATUS_CHANGE = 7,
MAX /// Used to detect invalid event type passed
};

View File

@ -19,8 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef RS_MSG_GUI_INTERFACE_H
#define RS_MSG_GUI_INTERFACE_H
#pragma once
#include <list>
#include <iostream>
@ -28,8 +27,11 @@
#include <set>
#include <assert.h>
#include "rstypes.h"
#include "rsgxsifacetypes.h"
#include "retroshare/rstypes.h"
#include "retroshare/rsgxsifacetypes.h"
#include "retroshare/rsevents.h"
#include "util/rsdeprecate.h"
#include "util/rsmemory.h"
/********************** For Messages and Channels *****************/
@ -93,9 +95,31 @@ const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ( 0x00000010 ) ; // requi
typedef uint64_t ChatLobbyId ;
typedef uint64_t ChatLobbyMsgId ;
typedef std::string ChatLobbyNickName ;
typedef std::string RsMailMessageId; // should be uint32_t !!
typedef uint64_t MessageId ;
typedef std::string RsMailMessageId; // TODO: rebase on t_RsGenericIdType
/**
* Used to return a tracker id so the API user can keep track of sent mail
* status
*/
struct RsMailTrackId : RsSerializable
{
RsMailTrackId(RsMailMessageId mailId, RsGxsId recipientId):
mMailId(mailId), mRecipientId(recipientId) {}
RsMailMessageId mMailId;
RsGxsId mRecipientId;
/// @see RsSerializable
void serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext &ctx ) override;
bool operator<(const RsMailTrackId& other) const;
bool operator==(const RsMailTrackId& other) const;
RsMailTrackId() = default;
~RsMailTrackId() override = default;
};
namespace Rs
{
@ -168,7 +192,6 @@ class MessageInfo_v2
struct MessageInfo : RsSerializable
{
MessageInfo(): msgflags(0), size(0), count(0), ts(0) {}
virtual ~MessageInfo() = default;
std::string msgId;
@ -202,7 +225,10 @@ struct MessageInfo : RsSerializable
int ts;
// RsSerializable interface
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
void serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext &ctx ) override
{
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(rspeerid_srcId);
@ -230,12 +256,13 @@ struct MessageInfo : RsSerializable
RS_SERIAL_PROCESS(ts);
}
~MessageInfo() override;
};
struct MsgInfoSummary : RsSerializable
{
MsgInfoSummary() : msgflags(0), count(0), ts(0) {}
virtual ~MsgInfoSummary() = default;
RsMailMessageId msgId;
RsPeerId srcId;
@ -260,6 +287,8 @@ struct MsgInfoSummary : RsSerializable
RS_SERIAL_PROCESS(count);
RS_SERIAL_PROCESS(ts);
}
~MsgInfoSummary() override;
};
struct MsgTagInfo : RsSerializable
@ -291,6 +320,22 @@ struct MsgTagType : RsSerializable
} //namespace Rs
} //namespace Msgs
struct RsMailStatusEvent : RsEvent
{
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
std::set<RsMailMessageId> mChangedMsgIds;
/// @see RsEvent
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx) override
{
RsEvent::serial_process(j, ctx);
RS_SERIAL_PROCESS(mChangedMsgIds);
}
~RsMailStatusEvent() override;
};
#define RS_CHAT_PUBLIC 0x0001
#define RS_CHAT_PRIVATE 0x0002
@ -426,11 +471,10 @@ public:
}
};
class VisibleChatLobbyRecord : RsSerializable
struct VisibleChatLobbyRecord : RsSerializable
{
public:
VisibleChatLobbyRecord(): lobby_id(0), total_number_of_peers(0), last_report_time(0){}
virtual ~VisibleChatLobbyRecord() = default;
VisibleChatLobbyRecord():
lobby_id(0), total_number_of_peers(0), last_report_time(0) {}
ChatLobbyId lobby_id ; // unique id of the lobby
std::string lobby_name ; // name to use for this lobby
@ -441,9 +485,11 @@ public:
rstime_t last_report_time ; // last time the lobby was reported.
ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE
// RsSerializable interface
public:
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
/// @see RsSerializable
void serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext &ctx) override
{
RS_SERIAL_PROCESS(lobby_id);
RS_SERIAL_PROCESS(lobby_name);
RS_SERIAL_PROCESS(lobby_topic);
@ -453,6 +499,8 @@ public:
RS_SERIAL_PROCESS(last_report_time);
RS_SERIAL_PROCESS(lobby_flags);
}
~VisibleChatLobbyRecord() override;
};
class ChatLobbyInfo : RsSerializable
@ -499,13 +547,6 @@ class RsMsgs
{
public:
RsMsgs() {}
virtual ~RsMsgs() = default;
/****************************************/
/* Message Items */
/****************************************/
/**
* @brief getMessageSummaries
* @jsonapi{development}
@ -523,6 +564,33 @@ public:
*/
virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0;
/**
* @brief sendMail
* @jsonapi{development}
* @param[in] from GXS id of the author
* @param[in] subject Mail subject
* @param[in] mailBody Mail body
* @param[in] to list of To: recipients
* @param[in] cc list of CC: recipients
* @param[in] bcc list of BCC: recipients
* @param[in] attachments list of suggested files
* @param[out] trackingIds storage for tracking ids for each sent mail
* @param[out] errorMsg error message if errors occurred, empty otherwise
* @return number of successfully sent mails
*/
virtual uint32_t sendMail(
const RsGxsId from,
const std::string& subject,
const std::string& mailBody,
const std::set<RsGxsId>& to = std::set<RsGxsId>(),
const std::set<RsGxsId>& cc = std::set<RsGxsId>(),
const std::set<RsGxsId>& bcc = std::set<RsGxsId>(),
const std::vector<FileInfo>& attachments = std::vector<FileInfo>(),
std::set<RsMailTrackId>& trackingIds =
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailTrackId>),
std::string& errorMsg =
RS_DEFAULT_STORAGE_PARAM(std::string) ) = 0;
/**
* @brief getMessageCount
* @jsonapi{development}
@ -535,14 +603,6 @@ public:
*/
virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) = 0;
/**
* @brief MessageSend
* @jsonapi{development}
* @param[in] info
* @return always true
*/
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
/**
* @brief SystemMessage
* @jsonapi{development}
@ -916,7 +976,14 @@ virtual bool initiateDistantChatConnexion(
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,DistantChatPeerInfo& info)=0;
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
/**
* @brief MessageSend
* @jsonapi{development}
* @param[in] info
* @return always true
*/
RS_DEPRECATED_FOR(sendMail)
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
virtual ~RsMsgs();
};
#endif

View File

@ -20,6 +20,7 @@
* *
*******************************************************************************/
#include <iostream>
#include <tuple>
#include "util/rsdir.h"
#include "util/rsdebug.h"
@ -300,6 +301,22 @@ bool p3Msgs::MessageSend(MessageInfo &info)
return mMsgSrv->MessageSend(info);
}
uint32_t p3Msgs::sendMail(
const RsGxsId from,
const std::string& subject,
const std::string& body,
const std::set<RsGxsId>& to,
const std::set<RsGxsId>& cc,
const std::set<RsGxsId>& bcc,
const std::vector<FileInfo>& attachments,
std::set<RsMailTrackId>& trackingIds,
std::string& errorMsg )
{
return mMsgSrv->sendMail(
from, subject, body, to, cc, bcc, attachments,
trackingIds, errorMsg );
}
bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
{
return mMsgSrv->SystemMessage(title, message, systemFlag);
@ -541,3 +558,28 @@ uint32_t p3Msgs::getDistantChatPermissionFlags()
return mChatSrv->getDistantChatPermissionFlags() ;
}
RsMsgs::~RsMsgs() = default;
RsMailStatusEvent::~RsMailStatusEvent() = default;
Rs::Msgs::MessageInfo::~MessageInfo() = default;
MsgInfoSummary::~MsgInfoSummary() = default;
VisibleChatLobbyRecord::~VisibleChatLobbyRecord() = default;
void RsMailTrackId::serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mMailId);
RS_SERIAL_PROCESS(mRecipientId);
}
bool RsMailTrackId::operator<(const RsMailTrackId& o) const
{
return std::tie( mMailId, mRecipientId) <
std::tie(o.mMailId, o.mRecipientId);
}
bool RsMailTrackId::operator==(const RsMailTrackId& o) const
{
return std::tie( mMailId, mRecipientId) ==
std::tie(o.mMailId, o.mRecipientId);
}

View File

@ -19,8 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef RS_P3MSG_INTERFACE_H
#define RS_P3MSG_INTERFACE_H
#pragma once
#include "retroshare/rsmsgs.h"
#include "retroshare/rsgxsifacetypes.h"
@ -40,9 +39,23 @@ class p3Msgs: public RsMsgs
{
public:
p3Msgs(p3MsgService *p3m, p3ChatService *p3c)
:mMsgSrv(p3m), mChatSrv(p3c) { return; }
virtual ~p3Msgs() { return; }
p3Msgs(p3MsgService *p3m, p3ChatService *p3c) :
mMsgSrv(p3m), mChatSrv(p3c) {}
~p3Msgs() override = default;
/// @see RsMsgs
uint32_t sendMail(
const RsGxsId from,
const std::string& subject,
const std::string& body,
const std::set<RsGxsId>& to = std::set<RsGxsId>(),
const std::set<RsGxsId>& cc = std::set<RsGxsId>(),
const std::set<RsGxsId>& bcc = std::set<RsGxsId>(),
const std::vector<FileInfo>& attachments = std::vector<FileInfo>(),
std::set<RsMailTrackId>& trackingIds =
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailTrackId>),
std::string& errorMsg =
RS_DEFAULT_STORAGE_PARAM(std::string) ) override;
/****************************************/
/* Message Items */
@ -54,6 +67,7 @@ class p3Msgs: public RsMsgs
virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg);
virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox);
RS_DEPRECATED_FOR(sendMail)
virtual bool MessageSend(Rs::Msgs::MessageInfo &info);
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId);
@ -172,6 +186,3 @@ class p3Msgs: public RsMsgs
p3MsgService *mMsgSrv;
p3ChatService *mChatSrv;
};
#endif

View File

@ -356,6 +356,9 @@ int p3MsgService::checkOutgoingMessages()
bool changed = false;
std::list<RsMsgItem*> output_queue;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
{
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -392,6 +395,7 @@ int p3MsgService::checkOutgoingMessages()
/* remove the pending flag */
output_queue.push_back(mit->second);
pEvent->mChangedMsgIds.insert(std::to_string(mit->first));
/* When the message is a distant msg, dont remove it yet from
* the list. Only mark it as being sent, so that we don't send
@ -446,6 +450,9 @@ int p3MsgService::checkOutgoingMessages()
if(changed)
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
if(rsEvents && !pEvent->mChangedMsgIds.empty())
rsEvents->postEvent(pEvent);
return 0;
}
@ -911,6 +918,8 @@ bool p3MsgService::removeMsgId(const std::string &mid)
}
bool changed = false;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -922,6 +931,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
RsMsgItem *mi = mit->second;
imsg.erase(mit);
delete mi;
pEvent->mChangedMsgIds.insert(mid);
}
mit = msgOutgoing.find(msgId);
@ -931,6 +941,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
RsMsgItem *mi = mit->second;
msgOutgoing.erase(mit);
delete mi;
pEvent->mChangedMsgIds.insert(mid);
}
std::map<uint32_t, RsMsgSrcId*>::iterator srcIt = mSrcIds.find(msgId);
@ -938,6 +949,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
changed = true;
delete (srcIt->second);
mSrcIds.erase(srcIt);
pEvent->mChangedMsgIds.insert(mid);
}
}
@ -950,6 +962,9 @@ bool p3MsgService::removeMsgId(const std::string &mid)
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
}
if(rsEvents && !pEvent->mChangedMsgIds.empty())
rsEvents->postEvent(pEvent);
return changed;
}
@ -1131,7 +1146,12 @@ uint32_t p3MsgService::sendMessage(RsMsgItem *item) // no from field because
uint32_t p3MsgService::sendDistantMessage(RsMsgItem *item, const RsGxsId& from)
{
if(!item) return 0;
if(!item)
{
RsErr() << __PRETTY_FUNCTION__ << " item can't be null" << std::endl;
print_stacktrace();
return 0;
}
item->msgId = getNewUniqueMsgId(); /* grabs Mtx as well */
item->msgFlags |= ( RS_MSG_FLAGS_DISTANT | RS_MSG_FLAGS_OUTGOING |
@ -1178,8 +1198,6 @@ bool p3MsgService::MessageSend(MessageInfo &info)
if (msg)
{
std::list<RsPgpId>::iterator it ;
if (msg->msgFlags & RS_MSG_FLAGS_SIGNED)
msg->msgFlags |= RS_MSG_FLAGS_SIGNATURE_CHECKS; // this is always true, since we are sending the message
@ -1192,14 +1210,106 @@ bool p3MsgService::MessageSend(MessageInfo &info)
imsg[msg->msgId] = msg;
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
//
// // return new message id
// rs_sprintf(info.msgId, "%lu", msg->msgId);
}
return true;
}
uint32_t p3MsgService::sendMail(
const RsGxsId from,
const std::string& subject,
const std::string& body,
const std::set<RsGxsId>& to,
const std::set<RsGxsId>& cc,
const std::set<RsGxsId>& bcc,
const std::vector<FileInfo>& attachments,
std::set<RsMailTrackId>& trackingIds,
std::string& errorMsg )
{
errorMsg.clear();
const std::string fname = __PRETTY_FUNCTION__;
auto pCheck = [&](bool test, const std::string& errMsg)
{
if(!test)
{
errorMsg = errMsg;
RsErr() << fname << " " << errMsg << std::endl;
}
return test;
};
if(!pCheck(!from.isNull(), "from can't be null")) return false;
if(!pCheck(!(to.empty() && cc.empty() && bcc.empty()),
"You must specify at least one recipient" )) return false;
auto dstCheck =
[&](const std::set<RsGxsId>& dstSet)
{
for(const RsGxsId& dst: dstSet) if(dst.isNull()) return false;
return true;
};
if(!pCheck(dstCheck(to), "to contains a null recipient" )) return false;
if(!pCheck(dstCheck(cc), "cc contains a null recipient" )) return false;
if(!pCheck(dstCheck(bcc), "bcc contains a null recipient")) return false;
MessageInfo msgInfo;
msgInfo.rsgxsid_srcId = from;
msgInfo.title = subject;
msgInfo.msg = body;
msgInfo.rsgxsid_msgto = to;
msgInfo.rsgxsid_msgcc = cc;
msgInfo.rsgxsid_msgbcc = bcc;
std::copy( attachments.begin(), attachments.end(),
std::back_inserter(msgInfo.files) );
uint32_t ret = 0;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
auto pSend = [&](const std::set<RsGxsId>& sDest)
{
for(const RsGxsId& dst : sDest)
{
RsMsgItem* msgItem = initMIRsMsg(msgInfo, dst);
if(!msgItem)
{
errorMsg += " initMIRsMsg from: " + from.toStdString()
+ " dst: " + dst.toStdString() + " subject: " + subject
+ " returned nullptr!\n";
RsErr() << fname << errorMsg;
continue;
}
uint32_t msgId = sendDistantMessage(msgItem, from);
// ensure we don't use that ptr again without noticing
msgItem = nullptr;
if(!msgId)
{
errorMsg += " sendDistantMessage from: " + from.toStdString()
+ " dst: " + dst.toStdString() + " subject: " + subject
+ " returned 0!\n";
RsErr() << fname << errorMsg;
continue;
}
const RsMailMessageId mailId = std::to_string(msgId);
pEvent->mChangedMsgIds.insert(mailId);
trackingIds.insert(RsMailTrackId(mailId, dst));
++ret;
}
};
pSend(to);
pSend(cc);
pSend(bcc);
if(rsEvents) rsEvents->postEvent(pEvent);
return ret;
}
bool p3MsgService::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
{
if ((systemFlag & RS_MSG_SYSTEM) == 0) {
@ -1890,20 +2000,21 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
{
RS_STACK_MUTEX(mMsgMtx);
std::cerr << "(WW) p3MsgService::notifyDataStatus: Global router tells "
<< "us that item ID " << id
<< " could not be delivered on time.";
auto it = _ongoing_messages.find(id);
if(it == _ongoing_messages.end())
{
std::cerr << " (EE) cannot find pending message to acknowledge. "
<< "Weird. grouter id = " << id << std::endl;
RsErr() << __PRETTY_FUNCTION__
<< " cannot find pending message to acknowledge. "
<< "Weird. grouter id: " << id << std::endl;
return;
}
uint32_t msg_id = it->second;
std::cerr << " message id = " << msg_id << std::endl;
RsWarn() << __PRETTY_FUNCTION__ << " Global router tells "
<< "us that item ID " << id
<< " could not be delivered on time. Message id: "
<< msg_id << std::endl;
/* this is needed because it's not saved in config, but we should
* probably include it in _ongoing_messages */
@ -1912,10 +2023,10 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
std::map<uint32_t,RsMsgItem*>::iterator mit = msgOutgoing.find(msg_id);
if(mit == msgOutgoing.end())
{
std::cerr << " (II) message has been notified as not delivered, "
RsInfo() << __PRETTY_FUNCTION__
<< " message has been notified as not delivered, "
<< "but it's not in outgoing list. Probably it has been "
<< "delivered successfully by other means."
<< std::endl;
<< "delivered successfully by other means." << std::endl;
}
else
{
@ -1925,6 +2036,7 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
// clear the routed flag so that the message is requested again
mit->second->msgFlags &= ~RS_MSG_FLAGS_ROUTED;
}
return;
}
@ -1954,16 +2066,30 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
return;
}
#if 0
delete it2->second;
msgOutgoing.erase(it2);
#else
// Do not delete it move to sent folder instead!
it2->second->msgFlags &= ~RS_MSG_FLAGS_PENDING;
imsg[msg_id] = it2->second;
msgOutgoing.erase(it2);
#endif
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
NOTIFY_TYPE_ADD );
IndicateConfigChanged();
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
if(rsEvents) rsEvents->postEvent(pEvent);
return;
}
std::cerr << "p3MsgService: unhandled data status info from global router"
RsErr() << __PRETTY_FUNCTION__
<< " unhandled data status info from global router"
<< " for msg ID " << id << ": this is a bug." << std::endl;
}
@ -2049,9 +2175,12 @@ bool p3MsgService::receiveGxsTransMail( const RsGxsId& authorId,
bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
GxsTransSendStatus status )
{
std::cout << __PRETTY_FUNCTION__ << " " << mailId << ", "
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
<< static_cast<uint>(status) << std::endl;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
{
uint32_t msg_id;
@ -2062,10 +2191,9 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
auto it = gxsOngoingMessages.find(mailId);
if(it == gxsOngoingMessages.end())
{
std::cerr << __PRETTY_FUNCTION__<< " "
<< mailId
<< ", " << static_cast<uint>(status)
<< " (EE) cannot find pending message to acknowledge!"
RsErr() << __PRETTY_FUNCTION__<< " " << mailId << ", "
<< static_cast<uint>(status)
<< " cannot find pending message to acknowledge!"
<< std::endl;
return false;
}
@ -2081,26 +2209,32 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
auto it2 = msgOutgoing.find(msg_id);
if(it2 == msgOutgoing.end())
{
std::cerr << __PRETTY_FUNCTION__ << " " << mailId
<< ", " << static_cast<uint>(status) << " (II) "
RsInfo() << __PRETTY_FUNCTION__ << " " << mailId
<< ", " << static_cast<uint>(status)
<< " received receipt for message that is not in "
<< "outgoing list, probably it has been acknoweldged "
<< "before by other means." << std::endl;
return true;
}
else
{
#if 0
delete it2->second;
msgOutgoing.erase(it2);
#else
// Do not delete it move to sent folder instead!
it2->second->msgFlags &= ~RS_MSG_FLAGS_PENDING;
imsg[msg_id] = it2->second;
msgOutgoing.erase(it2);
#endif
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
}
}
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
NOTIFY_TYPE_ADD );
IndicateConfigChanged();
return true;
}
if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
{
uint32_t msg_id;
@ -2132,16 +2266,21 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
std::cerr << " message has been notified as not delivered, "
<< "but it not on outgoing list."
<< std::endl;
return true;
}
else
{
std::cerr << " reseting the ROUTED flag so that the message is "
<< "requested again" << std::endl;
// clear the routed flag so that the message is requested again
mit->second->msgFlags &= ~RS_MSG_FLAGS_ROUTED;
return true;
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
}
}
}
if(rsEvents && !pEvent->mChangedMsgIds.empty())
rsEvents->postEvent(pEvent);
return true;
}

View File

@ -37,7 +37,7 @@
#include "services/p3service.h"
#include "rsitems/rsmsgitems.h"
#include "util/rsthreads.h"
#include "util/rsdebug.h"
#include "retroshare/rsgxsifacetypes.h"
#include "grouter/p3grouter.h"
@ -59,6 +59,19 @@ public:
virtual RsServiceInfo getServiceInfo();
/// @see RsMsgs::sendMail
uint32_t sendMail(const RsGxsId from,
const std::string& subject,
const std::string& body,
const std::set<RsGxsId>& to = std::set<RsGxsId>(),
const std::set<RsGxsId>& cc = std::set<RsGxsId>(),
const std::set<RsGxsId>& bcc = std::set<RsGxsId>(),
const std::vector<FileInfo>& attachments = std::vector<FileInfo>(),
std::set<RsMailTrackId>& trackingIds =
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailTrackId>),
std::string& errorMsg =
RS_DEFAULT_STORAGE_PARAM(std::string) );
/* External Interface */
bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList);
bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg);
@ -72,6 +85,7 @@ public:
// msgParentId == 0 --> remove
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
RS_DEPRECATED_FOR(sendMail)
bool MessageSend(Rs::Msgs::MessageInfo &info);
bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId);
@ -227,6 +241,8 @@ private:
bool mShouldEnableDistantMessaging ;
p3GxsTrans& mGxsTransServ;
RS_SET_CONTEXT_DEBUG_LEVEL(3)
};
#endif // MESSAGE_SERVICE_HEADER