diff --git a/src/main/kotlin/net/taehui/twilight/Avatar.kt b/src/main/kotlin/net/taehui/twilight/Avatar.kt index dce538c..020705a 100644 --- a/src/main/kotlin/net/taehui/twilight/Avatar.kt +++ b/src/main/kotlin/net/taehui/twilight/Avatar.kt @@ -195,7 +195,7 @@ } } - fun doNewSite(siteData: JSON.QwilightNewSite) { + fun putSite(siteData: JSON.QwilightNewSite) { if (siteData.siteName.isNotEmpty() && !siteData.siteName.startsWith("@")) { val siteID = UUID.randomUUID() if (siteData.isNetSite) { @@ -208,7 +208,7 @@ } } - fun doNewSilentSite(targetAvatarID: String) { + fun putSilentSite(targetAvatarID: String) { if (Utility.getDefaultAvatarID(avatarID) == Utility.getDefaultAvatarID( targetAvatarID ) diff --git a/src/main/kotlin/net/taehui/twilight/qwilight/QwilightAvatar.kt b/src/main/kotlin/net/taehui/twilight/qwilight/QwilightAvatar.kt index 47edb6b..5e991e2 100644 --- a/src/main/kotlin/net/taehui/twilight/qwilight/QwilightAvatar.kt +++ b/src/main/kotlin/net/taehui/twilight/qwilight/QwilightAvatar.kt @@ -765,11 +765,11 @@ } EventOuterClass.Event.EventID.NEW_SITE -> wantEstablished { - doNewSite(jm.readValue(eventText, JSON.QwilightNewSite::class.java)) + putSite(jm.readValue(eventText, JSON.QwilightNewSite::class.java)) } EventOuterClass.Event.EventID.NEW_SILENT_SITE -> wantEstablished { - doNewSilentSite( + putSilentSite( eventText ) } diff --git a/src/main/kotlin/net/taehui/twilight/site/SiteAvatar.kt b/src/main/kotlin/net/taehui/twilight/site/SiteAvatar.kt index 04ba3da..1761547 100644 --- a/src/main/kotlin/net/taehui/twilight/site/SiteAvatar.kt +++ b/src/main/kotlin/net/taehui/twilight/site/SiteAvatar.kt @@ -184,11 +184,11 @@ } EventOuterClass.Event.EventID.NEW_SITE -> wantEstablished { - doNewSite(jm.readValue(eventText, JSON.QwilightNewSite::class.java)) + putSite(jm.readValue(eventText, JSON.QwilightNewSite::class.java)) } EventOuterClass.Event.EventID.NEW_SILENT_SITE -> wantEstablished { - doNewSilentSite( + putSilentSite( eventText ) } diff --git a/src/main/kotlin/net/taehui/twilight/system/BannedNote.kt b/src/main/kotlin/net/taehui/twilight/system/BannedNote.kt index 274b99e..aac9f45 100644 --- a/src/main/kotlin/net/taehui/twilight/system/BannedNote.kt +++ b/src/main/kotlin/net/taehui/twilight/system/BannedNote.kt @@ -30,8 +30,8 @@ logInfo("Saved Banned Note") } - fun putBannedNoteFile(noteID: String, comment: String) { - bannedNoteStore[noteID] = comment + fun putBannedNoteFile(noteID: String, commentary: String) { + bannedNoteStore[noteID] = commentary } fun wipeBannedNoteFile(noteID: String) { diff --git a/src/main/kotlin/net/taehui/twilight/system/DB.kt b/src/main/kotlin/net/taehui/twilight/system/DB.kt index 5292ccd..7d409cb 100644 --- a/src/main/kotlin/net/taehui/twilight/system/DB.kt +++ b/src/main/kotlin/net/taehui/twilight/system/DB.kt @@ -2317,19 +2317,19 @@ SELECT COUNT(DISTINCT Note_ID, Avatar) FROM tw_comment WHERE tw_note.Note_ID = tw_comment.Note_ID - ) AS Highest, ( + ) AS Highest_Count, ( SELECT COUNT(Comment_ID) FROM tw_comment WHERE tw_note.Note_ID = tw_comment.Note_ID - ) AS Total, ( + ) AS Total_Count, ( SELECT MAX(Date) FROM tw_comment WHERE tw_note.Note_ID = tw_comment.Note_ID ) AS Date """.trimIndent() val fitStatement = when (fit) { - 0 -> " ORDER BY Highest DESC " - 1 -> " ORDER BY Total DESC " + 0 -> " ORDER BY Highest_Count DESC " + 1 -> " ORDER BY Total_Count DESC " 2 -> " ORDER BY Date DESC " 3 -> " ORDER BY Title " 4 -> " ORDER BY Artist " @@ -2395,8 +2395,8 @@ val genre = rows.getString("Genre") val levelText = rows.getString("Level_Text") val level = rows.getInt("Level") - val highestCount = rows.getInt("Highest") - val totalCount = rows.getInt("Total") + val highestCount = rows.getInt("Highest_Count") + val totalCount = rows.getInt("Total_Count") val date = rows.getTimestamp("Date") }) } diff --git a/src/main/kotlin/net/taehui/twilight/system/IO.kt b/src/main/kotlin/net/taehui/twilight/system/IO.kt index 6d2dda1..d7acbdf 100644 --- a/src/main/kotlin/net/taehui/twilight/system/IO.kt +++ b/src/main/kotlin/net/taehui/twilight/system/IO.kt @@ -90,11 +90,13 @@ SiteHandler.setSiteNotify( SiteHandler.getSiteID(w[1]), w[2] ) + continue } else if (w.size > 1) { AvatarHandler.doNotify(w[1]) - } else { - logInfo("alarm ") + continue } + + logInfo("alarm ") } "avatar" -> { @@ -108,10 +110,8 @@ "quit" -> { if (w.size > 2) { AvatarHandler.handleNotSignIn(w[2]) - } else { - logInfo("avatar quit ") + continue } - continue } "ban" -> { @@ -130,26 +130,22 @@ logInfo("Failed to Find ID") } } - } else { - logInfo("avatar ban ") + continue } - continue } "allow" -> { if (w.size > 2) { BannedIP.wipeBannedIP(w[2]) - } else { - logInfo("avatar allow ") + continue } - continue } } } - logInfo("avatar [view] View Avatars") - logInfo("avatar [quit] Quit Avatar") - logInfo("avatar [ban] Ban Avatar IP") - logInfo("avatar [allow] Allow Avatar IP") + logInfo("avatar view View Avatars") + logInfo("avatar quit Quit Avatar") + logInfo("avatar ban Ban Avatar IP") + logInfo("avatar allow Allow Avatar IP") } "awilight" -> { @@ -163,14 +159,13 @@ AwilightHandler.setAwilightCount( awilightCount ) - } else { - logInfo("awilight set ") + continue } - continue } } } - logInfo("awilight [set] Set Awilight") + + logInfo("awilight set Set Awilight") } "bundle" -> { @@ -187,7 +182,8 @@ } } } - logInfo("bundle [wipe] Clean Bundle Files") + + logInfo("bundle wipe Clean Bundle Files") } "comment" -> { @@ -226,8 +222,8 @@ } } - logInfo("comment [learn] Learn Comments") - logInfo("comment [wipe] Clean Comment Files") + logInfo("comment learn Learn Comments") + logInfo("comment wipe Clean Comment Files") } "future" -> { @@ -289,7 +285,7 @@ } } - logInfo("handled [learn] Learn Handled") + logInfo("handled learn Learn Handled") } "note" -> { @@ -343,20 +339,18 @@ "ban" -> { if (w.size > 3) { - BannedNote.putBannedNoteFile(w[2], w[3]) - } else { - logInfo("note ban ") + val noteID = w[2] + BannedNote.putBannedNoteFile(noteID, w[3]) + DB.wipeNote(noteID, this) + continue } - continue } "allow" -> { if (w.size > 2) { BannedNote.wipeBannedNoteFile(w[2]) - } else { - logInfo("note allow ") + continue } - continue } "wipe" -> { @@ -388,11 +382,12 @@ } } } - logInfo("note [learn] Learn Notes") - logInfo("note [ban] Ban Note") - logInfo("note [allow] Allow Note") - logInfo("note [wipe] Clean or Wipe Note File") - logInfo("note [pms] PMS Note File") + + logInfo("note learn Learn Notes") + logInfo("note ban Ban Note") + logInfo("note allow Allow Note") + logInfo("note wipe Clean or Wipe Note File") + logInfo("note pms PMS Note File") } "pause" -> { @@ -410,12 +405,11 @@ "avatar" -> { if (w.size > 3) { PlatformIDSystem.putPlatformID(w[2], w[3]) + continue } else if (w.size > 2) { PlatformIDSystem.wipePlatformID(w[2]) - } else { - logInfo("platform avatar ") + continue } - continue } "view" -> { @@ -434,10 +428,11 @@ } } } - logInfo("platform [avatar] Handle Avatars") - logInfo("platform [view] View Platform") - logInfo("platform [dispose] Close Platform") - logInfo("platform [handle] Handle Platform") + + logInfo("platform avatar Handle Avatar") + logInfo("platform view View Platform") + logInfo("platform dispose Close Platform") + logInfo("platform handle Handle Platform") } "ram" -> { @@ -460,35 +455,29 @@ "put" -> { if (w.size > 2) { SiteHandler.putSite(w[2]) - } else { - logInfo("site put ") + continue } - continue } "wipe" -> { if (w.size > 2) { SiteHandler.wipeSite(SiteHandler.getSiteID(w[2])) - } else { - logInfo("site wipe ") + continue } - continue } "silent" -> { if (w.size > 2) { SiteHandler.silentSite(SiteHandler.getSiteID(w[2])) - } else { - logInfo("site silent ") + continue } - continue } } } - logInfo("site [view] View Sites") - logInfo("site [put] Put Site") - logInfo("site [wipe] Wipe Site") - logInfo("site [silent] Silent Site") + logInfo("site view View Sites") + logInfo("site put Put Site") + logInfo("site wipe Wipe Site") + logInfo("site silent Silent Site") } "tv" -> { @@ -510,24 +499,24 @@ } } } - logInfo("tv [view] View TV") - logInfo("tv [dispose] Close TV") - logInfo("tv [handle] Handle TV") + logInfo("tv view View TV") + logInfo("tv dispose Close TV") + logInfo("tv handle Handle TV") } else -> { - logInfo("[alarm] Send Notify") - logInfo("[avatar] Handle Avatars") - logInfo("[awilight] Handle Awilight") - logInfo("[bundle] Handle Bundles") - logInfo("[comment] Handle Comments") - logInfo("[future] View Futures") - logInfo("[note] Handle Notes") - logInfo("[pause] Pause Twilight") - logInfo("[platform] Handle Platform") - logInfo("[site] Handle Sites") - logInfo("[tv] Handle TV") - logInfo("[stop] Stop Twilight") + logInfo("[alarm Send Notify") + logInfo("[avatar Handle Avatars") + logInfo("[awilight Handle Awilight") + logInfo("[bundle Handle Bundles") + logInfo("[comment Handle Comments") + logInfo("[future View Futures") + logInfo("[note Handle Notes") + logInfo("[pause Pause Twilight") + logInfo("[platform Handle Platform") + logInfo("[site Handle Sites") + logInfo("[tv Handle TV") + logInfo("[stop Stop Twilight") } } } diff --git a/src/main/kotlin/net/taehui/twilight/www/WwwAvatar.kt b/src/main/kotlin/net/taehui/twilight/www/WwwAvatar.kt index 3c28bb1..d32bcb9 100644 --- a/src/main/kotlin/net/taehui/twilight/www/WwwAvatar.kt +++ b/src/main/kotlin/net/taehui/twilight/www/WwwAvatar.kt @@ -1,6 +1,7 @@ package net.taehui.twilight.www import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue import io.netty.buffer.ByteBufUtil import io.netty.buffer.Unpooled import io.netty.channel.ChannelFutureListener @@ -593,6 +594,16 @@ ) } + "/qwilight/www/toil" -> { + QwilightLogging(loggerID).logInfo( + msg.content().toString(StandardCharsets.UTF_8) + ) + ctx.writeAndFlush(DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CREATED)) + .addListener( + ChannelFutureListener.CLOSE + ) + } + "/qwilight/www/note" -> { val noteFileData = ByteBufUtil.getBytes(msg.content()) var isBanned = false