@ -56,11 +56,11 @@ public class ReportService {
restTemplate = new RestTemplate ( ) ;
}
private void addReport ( PlayerProfile current_user , PlayerProfile reported_user , String text , ReportType reportType ) {
private int addReport ( PlayerProfile current_user , PlayerProfile reported_user , String text , ReportType reportType ) {
PlayerOnServer current_player = ( PlayerOnServer ) statsService . searchPlayer ( current_user ) ;
PlayerOnServer reported_player = ( PlayerOnServer ) statsService . searchPlayer ( reported_user ) ;
jdbcTemplate_rw . update ( "INSERT INTO user_reports (a_nickname, a_steam2, a_permition, a_kills, a_deads, a_seconds, " +
return jdbcTemplate_rw . update ( "INSERT INTO user_reports (a_nickname, a_steam2, a_permition, a_kills, a_deads, a_seconds, " +
"r_nickname, r_steam2, r_permition, r_kills, r_deads, r_seconds, " +
"reasons, utime, srv, online, type) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" ,
current_player = = null ? current_user . getSteam_data ( ) . getNickname ( ) : current_player . getName ( ) , current_user . getSteamids ( ) . steam2 , Permition2Prefix ( current_user . getPermition ( ) ) . ordinal ( ) ,
@ -78,6 +78,10 @@ public class ReportService {
reportType . ordinal ( ) ) ;
}
public int addReportAction ( int report_id , String action ) {
return jdbcTemplate_rw . update ( "INSERT INTO user_reports_action (report_id, action) VALUES (?, ?)" , report_id , action ) ;
}
public long getCreatedReportsCount ( SteamID steamID ) {
return jdbcTemplate_ro . query ( "SELECT COUNT(*) as c FROM user_reports WHERE a_steam2 LIKE ?" , new Object [ ] { steamID . steam2 } , ( rs , n ) - > rs . getLong ( "c" ) ) . get ( 0 ) ;
}
@ -106,16 +110,16 @@ public class ReportService {
( Instant . now ( ) . getEpochSecond ( ) - userKD . get ( current_user . getSteamids ( ) . steam64 ) ) < kd ) {
return ( Instant . now ( ) . getEpochSecond ( ) - userKD . get ( current_user . getSteamids ( ) . steam64 ) ) - kd ;
}
addReport ( current_user , reported_user , text , reportType ) ;
long res = createReportToDiscord ( current_user , reported_user , text ) ;
int report_id = addReport ( current_user , reported_user , text , reportType ) ;
long res = createReportToDiscord ( current_user , reported_user , text , report_id ) ;
if ( res = = 0 ) return 0 ;
userKD . merge ( current_user . getSteamids ( ) . steam64 , res , ( x , y ) - > y ) ;
return res ;
}
case IN_GAME - > {
addReport ( current_user , reported_user , text , reportType ) ;
return createReportToDiscord ( current_user , reported_user , text ) ;
int report_id = addReport ( current_user , reported_user , text , reportType ) ;
return createReportToDiscord ( current_user , reported_user , text , report_id ) ;
}
default - > {
return - 1 ;
@ -123,7 +127,7 @@ public class ReportService {
}
}
private long createReportToDiscord ( PlayerProfile current_user , PlayerProfile reported_user , String text ) {
private long createReportToDiscord ( PlayerProfile current_user , PlayerProfile reported_user , String text , int report_id ) {
PlayerOnServer current_player = ( PlayerOnServer ) statsService . searchPlayer ( current_user ) ;
String author = "%s | %s%s | %s" . formatted (
current_player = = null ? current_user . getSteam_data ( ) . getNickname ( ) : current_player . getName ( ) ,
@ -157,7 +161,7 @@ public class ReportService {
embed . put ( "url" , reported_user . getSteamids ( ) . community_url ) ;
}
embed . put ( "description" , text ) ;
embed . put ( "color" , 16581375 ) ; // 255 * 255 * 255 | black
embed . put ( "color" , report_id ) ; // 255 * 255 * 255 | black
embed . put ( "footer" , Map . of (
"text" , "%s • %d/%d " . formatted (
stats . getServers ( ) . get ( reported_user = = null ? current_user . getPlay_on ( ) . getServer_id ( ) : reported_user . getPlay_on ( ) . getServer_id ( ) ) . getName ( ) ,