Skip to content

Commit

Permalink
moderate
Browse files Browse the repository at this point in the history
  • Loading branch information
mazrean committed Nov 25, 2023
1 parent 584e66c commit 23e51b9
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions app/go/livecomment_handler.go
Expand Up @@ -375,28 +375,11 @@ func moderateHandler(c echo.Context) error {

// NGワードにヒットする過去の投稿も全削除する
for _, ngword := range ngwords {
// ライブコメント一覧取得
var livecomments []*LivecommentModel
if err := tx.SelectContext(ctx, &livecomments, "SELECT * FROM livecomments"); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "failed to get livecomments: "+err.Error())
}

for _, livecomment := range livecomments {
query := `
query := `
DELETE FROM livecomments
WHERE
id = ? AND
livestream_id = ? AND
(SELECT COUNT(*)
FROM
(SELECT ? AS text) AS texts
INNER JOIN
(SELECT CONCAT('%', ?, '%') AS pattern) AS patterns
ON texts.text LIKE patterns.pattern) >= 1;
`
if _, err := tx.ExecContext(ctx, query, livecomment.ID, livestreamID, livecomment.Comment, ngword.Word); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "failed to delete old livecomments that hit spams: "+err.Error())
}
WHERE livestream_id = ? AND comment LIKE CONCAT('%', ?, '%')`
if _, err := tx.ExecContext(ctx, query, livestreamID, ngword.Word); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "failed to delete old livecomments that hit spams: "+err.Error())
}
}

Expand Down

0 comments on commit 23e51b9

Please sign in to comment.