Browse Source

daemon: implement redis chanmod trigger

Andrew Dolgov 7 months ago
parent
commit
f547789caf

+ 1 - 1
daemon/src/main/java/org/fox/ttirc/Master.java

@@ -310,7 +310,7 @@ public class Master {
 				readOption(reader, m_prefs, "DB_NAME", "Database name", "ttirc_db");
 				readOption(reader, m_prefs, "DB_USER", "Database user", "ttirc_user");
 				readOption(reader, m_prefs, "DB_PASS", "Database password", "ttirc_pwd");
-				readOption(reader, m_prefs, "DB_TIMEZONE", "Database timezone", "UTC");
+				readOption(reader, m_prefs, "DB_TIMEZONE", "Database timezone (same as DB_TIMEZONE in config.php)", "UTC");
 				readOption(reader, m_prefs, "REDIS_HOST", "Redis hostname", "127.0.0.1");
 				readOption(reader, m_prefs, "REDIS_PORT", "Redis port", "6379");
 

+ 22 - 0
daemon/src/main/java/org/fox/ttirc/NativeConnectionHandler.java

@@ -123,6 +123,8 @@ public class NativeConnectionHandler extends ConnectionHandler {
 		} catch (SQLException e) {
 			e.printStackTrace();
 		}
+
+		updateLastChanmod();
 	}
 
 	private void setActive(boolean active) {
@@ -232,6 +234,8 @@ public class NativeConnectionHandler extends ConnectionHandler {
 			ps.execute();
 			ps.close();
 
+			updateLastChanmod();
+
 			if (ssl)
 				m_irc = new SSLIRCConnection(host, port, port, pass, nick, email, realname);
 			else
@@ -729,6 +733,8 @@ public class NativeConnectionHandler extends ConnectionHandler {
 			e.printStackTrace();
 		}
 
+		updateLastChanmod();
+
 		pushMessage("---", "DISCONNECT", "", Constants.MSGT_EVENT);
 
 		try {
@@ -752,6 +758,7 @@ public class NativeConnectionHandler extends ConnectionHandler {
 		ps.execute();
 		ps.close();
 
+		updateLastChanmod();
 	}
 
 	private void syncTopic(String channel, String topic) throws SQLException {
@@ -765,6 +772,8 @@ public class NativeConnectionHandler extends ConnectionHandler {
 
 		ps.execute();
 		ps.close();
+
+		updateLastChanmod();
 	}
 
 	private void syncTopic(String channel, String owner, long topicSet) throws SQLException {
@@ -779,6 +788,8 @@ public class NativeConnectionHandler extends ConnectionHandler {
 
 		ps.execute();
 		ps.close();
+
+		updateLastChanmod();
 	}
 
 	private void checkChannel(String channel, int chanType) throws SQLException {
@@ -802,6 +813,14 @@ public class NativeConnectionHandler extends ConnectionHandler {
 			ps.setInt(3, chanType);
 			ps.execute();
 			ps.close();
+
+			updateLastChanmod();
+		}
+	}
+
+	protected void updateLastChanmod() {
+		try (Jedis jedis = m_master.getJedis()) {
+			jedis.incr("ttirc_last_chanmod," + m_ownerUid);
 		}
 	}
 
@@ -814,6 +833,8 @@ public class NativeConnectionHandler extends ConnectionHandler {
 		ps.setInt(2, m_connectionId);
 		ps.execute();
 		ps.close();
+
+		updateLastChanmod();
 	}
 
 	private Vector<String> getChannels() throws SQLException {
@@ -849,6 +870,7 @@ public class NativeConnectionHandler extends ConnectionHandler {
 			e.printStackTrace();
 		}
 
+		updateLastChanmod();
 	}
 
 	private void syncServer() throws SQLException {

+ 1 - 0
daemon/src/main/java/org/fox/ttirc/NickList.java

@@ -307,6 +307,7 @@ public class NickList {
 			e.printStackTrace();
 		}
 
+		handler.updateLastChanmod();
 	}
 
 	/*public Vector<Nick> getNicks(String chan) {