1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 00:23:11 +02:00

mysql_insert_id doesn't return an id if one isnt generated, so

check that it really returns a value before using it.
Also fix memos to cleanup after themselves when deleted.
This commit is contained in:
Adam
2013-01-25 03:09:51 -05:00
parent 3769cc1a35
commit 76d9e58ae5
8 changed files with 43 additions and 51 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ class CommandMSCancel : public Command
const Anope::string &nname = params[0];
bool ischan;
MemoInfo *mi = MemoServService->GetMemoInfo(nname, ischan);
MemoInfo *mi = MemoInfo::GetMemoInfo(nname, ischan);
if (mi == NULL)
source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), nname.c_str());
+1 -1
View File
@@ -44,7 +44,7 @@ class CommandMSIgnore : public Command
}
bool ischan;
MemoInfo *mi = MemoServService->GetMemoInfo(channel, ischan);
MemoInfo *mi = MemoInfo::GetMemoInfo(channel, ischan);
ChannelInfo *ci = ChannelInfo::Find(channel);
if (!mi)
source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), channel.c_str());
+1 -1
View File
@@ -63,7 +63,7 @@ class CommandMSRSend : public Command
source.Reply(_("Memo sent to \002%s\002."), name.c_str());
bool ischan;
MemoInfo *mi = MemoServService->GetMemoInfo(nick, ischan);
MemoInfo *mi = MemoInfo::GetMemoInfo(nick, ischan);
if (mi == NULL)
throw CoreException("NULL mi in ms_rsend");
Memo *m = (mi->memos->size() ? mi->GetMemo(mi->memos->size() - 1) : NULL);
+1 -1
View File
@@ -109,7 +109,7 @@ class DBMySQL : public Module, public Pipe
this->RunQueryResult(create[i]);
Result res = this->RunQueryResult(this->SQL->BuildInsert(this->prefix + s_type->GetName(), obj->id, *data));
if (obj->id != res.GetID())
if (res.GetID() && obj->id != res.GetID())
{
/* In this case obj is new, so place it into the object map */
obj->id = res.GetID();
+1 -21
View File
@@ -39,30 +39,10 @@ class MyMemoServService : public MemoServService
public:
MyMemoServService(Module *m) : MemoServService(m) { }
MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan) anope_override
{
if (!target.empty() && target[0] == '#')
{
ischan = true;
ChannelInfo *ci = ChannelInfo::Find(target);
if (ci != NULL)
return &ci->memos;
}
else
{
ischan = false;
NickAlias *na = NickAlias::Find(target);
if (na != NULL)
return &na->nc->memos;
}
return NULL;
}
MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) anope_override
{
bool ischan;
MemoInfo *mi = this->GetMemoInfo(target, ischan);
MemoInfo *mi = MemoInfo::GetMemoInfo(target, ischan);
if (mi == NULL)
return MEMO_INVALID_TARGET;
-7
View File
@@ -14,13 +14,6 @@ class MemoServService : public Service
MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") { }
/** Retrieve the memo info for a nick or channel
* @param target Target
* @param ischan Set to true if target is a channel
* @return A memoinfo structure or NULL
*/
virtual MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan) = 0;
/** Sends a memo.
* @param source The source of the memo, can be anythin.
* @param target The target of the memo, nick or channel.