mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix: purge excess guild posts and clarify alliance TODO
Purge oldest guild posts beyond the limit (100 messages, 4 news) after each new post is created. Replace misleading alliance application TODO with a note that the feature is not yet implemented.
This commit is contained in:
@@ -1953,7 +1953,14 @@ func handleMsgMhfUpdateGuildMessageBoard(s *Session, p mhfpacket.MHFPacket) {
|
||||
switch pkt.MessageOp {
|
||||
case 0: // Create message
|
||||
_, _ = s.server.db.Exec("INSERT INTO guild_posts (guild_id, author_id, stamp_id, post_type, title, body) VALUES ($1, $2, $3, $4, $5, $6)", guild.ID, s.charID, pkt.StampID, pkt.PostType, pkt.Title, pkt.Body)
|
||||
// TODO: if there are too many messages, purge excess
|
||||
maxPosts := 100
|
||||
if pkt.PostType == 1 {
|
||||
maxPosts = 4
|
||||
}
|
||||
_, _ = s.server.db.Exec(`DELETE FROM guild_posts WHERE id IN (
|
||||
SELECT id FROM guild_posts WHERE guild_id = $1 AND post_type = $2
|
||||
ORDER BY created_at DESC OFFSET $3
|
||||
)`, guild.ID, pkt.PostType, maxPosts)
|
||||
case 1: // Delete message
|
||||
_, _ = s.server.db.Exec("DELETE FROM guild_posts WHERE id = $1", pkt.PostID)
|
||||
case 2: // Update message
|
||||
|
||||
@@ -151,7 +151,8 @@ func handleMsgMhfOperateJoint(s *Session, p mhfpacket.MHFPacket) {
|
||||
} else {
|
||||
_, _ = s.server.db.Exec(`UPDATE guild_alliances SET sub2_id = NULL WHERE id = $1`, alliance.ID)
|
||||
}
|
||||
// TODO: Handle deleting Alliance applications
|
||||
// NOTE: Alliance join requests are not yet implemented (no DB table exists),
|
||||
// so there are no pending applications to clean up on leave.
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
} else {
|
||||
s.logger.Warn(
|
||||
|
||||
Reference in New Issue
Block a user