String Checkable::AddComment(CommentType entryType, const String& author,
    const String& text, double expireTime, const String& id, const MessageOrigin& origin)
{
	String uid;

	if (id.IsEmpty())
		uid = Utility::NewUniqueID();
	else
		uid = id;

	Comment::Ptr comment = new Comment();
	comment->SetId(uid);;
	comment->SetEntryTime(Utility::GetTime());
	comment->SetEntryType(entryType);
	comment->SetAuthor(author);
	comment->SetText(text);
	comment->SetExpireTime(expireTime);

	int legacy_id;

	{
		boost::mutex::scoped_lock lock(l_CommentMutex);
		legacy_id = l_NextCommentID++;
	}

	comment->SetLegacyId(legacy_id);

	GetComments()->Set(uid, comment);

	{
		boost::mutex::scoped_lock lock(l_CommentMutex);
		l_LegacyCommentsCache[legacy_id] = uid;
		l_CommentsCache[uid] = this;
	}

	OnCommentAdded(this, comment, origin);

	return uid;
}
Beispiel #2
0
String Service::AddComment(CommentType entryType, const String& author,
    const String& text, double expireTime, const String& id, const String& authority)
{
	String uid;

	if (id.IsEmpty())
		uid = Utility::NewUniqueID();
	else
		uid = id;

	Comment::Ptr comment = make_shared<Comment>();
	comment->SetId(uid);;
	comment->SetEntryTime(Utility::GetTime());
	comment->SetEntryType(entryType);
	comment->SetAuthor(author);
	comment->SetText(text);
	comment->SetExpireTime(expireTime);

	int legacy_id;

	{
		boost::mutex::scoped_lock lock(l_CommentMutex);
		legacy_id = l_NextCommentID++;
	}

	comment->SetLegacyId(legacy_id);

	GetComments()->Set(uid, comment);

	{
		boost::mutex::scoped_lock lock(l_CommentMutex);
		l_LegacyCommentsCache[legacy_id] = uid;
		l_CommentsCache[uid] = GetSelf();
	}

	OnCommentAdded(GetSelf(), comment, authority);

	return uid;
}