View Issue Details

IDProjectCategoryView StatusLast Update
0001679Anope Stable (2.0.x series)Generalpublic2016-11-05 16:37
Reportercapitaine Assigned ToAdam  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0001679: IRC2SQL does not update status modes
DescriptionFrom IRC2SQL, users status modes like +vho are updated only on join, but not when staying in a channel.
Steps To Reproduce/MODE #Foo +vho John

mysql> SELECT i.modes FROM irc_user AS u, irc_ison AS i, irc_chan AS c WHERE u.nick = "John" AND c.channel = "#Foo" AND u.nickid = i.nickid AND c.chanid = i.chanid;

+-------+
| modes |
+-------+
| |
+-------+
Additional InformationSuggested fix attached
TagsNo tags attached.

Activities

Adam

2016-11-05 16:37

administrator   ~0006814

Thanks, fixed in a5fdf7c546ccb0f70a70543ea8afb54d155a13cc

cronus

2016-05-29 02:54

developer   ~0006795

Didn't notice you used another table, Im use to JOINs on other tables :P

capitaine

2016-05-28 22:07

reporter   ~0006794

I know, my report is about ison.modes, not tables channels.modes nor user.modes

cronus

2016-05-28 21:58

developer   ~0006793

That table has modes for user modes, not channel modes. The Channel modes you seek are in the "ison" table.

capitaine

2016-05-28 21:53

reporter  

0001-IRC2SQL-update-status-modes.patch (1,712 bytes)   
From 29d502ce7495ed9dc348184abd5563fe3bd81d28 Mon Sep 17 00:00:00 2001
From: Capitaine
Date: Sat, 28 May 2016 22:08:38 +0200
Subject: [PATCH] IRC2SQL update status modes

---
 modules/extra/stats/irc2sql/irc2sql.cpp | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/modules/extra/stats/irc2sql/irc2sql.cpp b/modules/extra/stats/irc2sql/irc2sql.cpp
index a001813..b510443 100644
--- a/modules/extra/stats/irc2sql/irc2sql.cpp
+++ b/modules/extra/stats/irc2sql/irc2sql.cpp
@@ -223,10 +223,29 @@ void IRC2SQL::OnJoinChannel(User *u, Channel *c)
 
 EventReturn IRC2SQL::OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param)
 {
-	query = "UPDATE `" + prefix + "chan` SET modes=@modes@ WHERE channel=@channel@";
-	query.SetValue("channel", c->name);
-	query.SetValue("modes", c->GetModes(true,true));
-	this->RunQuery(query);
+	User *u = NULL;
+	if (!param.empty() && (u = User::Find(param, false)))
+	{
+		ChanUserContainer *cc = u->FindChannel(c);
+		if (cc)
+		{
+			query = "UPDATE `" + prefix + "user` AS u, `" + prefix + "ison` AS i, `" + prefix + "chan` AS c"
+					" SET i.modes=@modes@"
+					" WHERE u.nick=@nick@ AND c.channel=@channel@"
+						" AND u.nickid = i.nickid AND c.chanid = i.chanid";
+			query.SetValue("nick", u->nick);
+			query.SetValue("modes", cc->status.Modes());
+			query.SetValue("channel", c->name);
+			this->RunQuery(query);
+		}
+	}
+	else
+	{
+		query = "UPDATE `" + prefix + "chan` SET modes=@modes@ WHERE channel=@channel@";
+		query.SetValue("channel", c->name);
+		query.SetValue("modes", c->GetModes(true,true));
+		this->RunQuery(query);
+	}
 	return EVENT_CONTINUE;
 }
 
-- 
2.1.4

Issue History

Date Modified Username Field Change
2016-05-28 21:53 capitaine New Issue
2016-05-28 21:53 capitaine File Added: 0001-IRC2SQL-update-status-modes.patch
2016-05-28 21:58 cronus Note Added: 0006793
2016-05-28 22:07 capitaine Note Added: 0006794
2016-05-29 02:54 cronus Note Added: 0006795
2016-11-05 16:37 Adam Note Added: 0006814
2016-11-05 16:37 Adam Status new => resolved
2016-11-05 16:37 Adam Resolution open => fixed
2016-11-05 16:37 Adam Assigned To => Adam