Added migration to update event types of older messages.

This commit is contained in:
flash 2024-05-10 19:23:19 +00:00
parent a6569815af
commit 795a87fe56
2 changed files with 9 additions and 5 deletions

View file

@ -30,6 +30,15 @@ namespace SharpChat.EventStorage {
DoMigration("create_events_table", CreateEventsTable);
DoMigration("allow_null_target", AllowNullTarget);
DoMigration("update_event_type_names", UpdateEventTypeNames);
}
private void UpdateEventTypeNames() {
RunCommand(@"UPDATE sqc_events SET event_type = ""msg:add"" WHERE event_type = ""SharpChat.Events.ChatMessage""");
RunCommand(@"UPDATE sqc_events SET event_type = ""user:connect"" WHERE event_type = ""SharpChat.Events.UserConnectEvent""");
RunCommand(@"UPDATE sqc_events SET event_type = ""user:disconnect"" WHERE event_type = ""SharpChat.Events.UserDisconnectEvent""");
RunCommand(@"UPDATE sqc_events SET event_type = ""chan:join"" WHERE event_type = ""SharpChat.Events.UserChannelJoinEvent""");
RunCommand(@"UPDATE sqc_events SET event_type = ""chan:leave"" WHERE event_type = ""SharpChat.Events.UserChannelLeaveEvent""");
}
private void AllowNullTarget() {

View file

@ -26,7 +26,6 @@ namespace SharpChat.Packet {
switch(Event.Type) {
case "msg:add":
case "SharpChat.Events.ChatMessage":
if(isBroadcast) {
sb.Append(V1_CHATBOT);
} else {
@ -58,22 +57,18 @@ namespace SharpChat.Packet {
break;
case "user:connect":
case "SharpChat.Events.UserConnectEvent":
sb.AppendFormat("{0}\t0\fjoin\f{1}", V1_CHATBOT, Event.Sender?.LegacyName);
break;
case "chan:join":
case "SharpChat.Events.UserChannelJoinEvent":
sb.AppendFormat("{0}\t0\fjchan\f{1}", V1_CHATBOT, Event.Sender?.LegacyName);
break;
case "chan:leave":
case "SharpChat.Events.UserChannelLeaveEvent":
sb.AppendFormat("{0}\t0\flchan\f{1}", V1_CHATBOT, Event.Sender?.LegacyName);
break;
case "user:disconnect":
case "SharpChat.Events.UserDisconnectEvent":
sb.AppendFormat(
"{0}\t0\f{1}\f{2}",
V1_CHATBOT,