mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-01 15:49:58 -08:00
replays expire after two weeks, lock can be toggled to prevent that
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "pb/command_deck_del.pb.h"
|
||||
#include "pb/command_replay_list.pb.h"
|
||||
#include "pb/command_replay_download.pb.h"
|
||||
#include "pb/command_replay_modify_match.pb.h"
|
||||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/event_server_message.pb.h"
|
||||
#include "pb/event_server_identification.pb.h"
|
||||
@@ -499,7 +500,7 @@ Response::ResponseCode ServerSocketInterface::cmdReplayList(const Command_Replay
|
||||
|
||||
servatrice->dbMutex.lock();
|
||||
QSqlQuery query1;
|
||||
query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player");
|
||||
query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr, a.do_not_hide from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player and (a.do_not_hide = 1 or date_add(b.time_started, interval 14 day) > now())");
|
||||
query1.bindValue(":id_player", userInfo->id());
|
||||
servatrice->execSqlQuery(query1);
|
||||
while (query1.next()) {
|
||||
@@ -514,6 +515,7 @@ Response::ResponseCode ServerSocketInterface::cmdReplayList(const Command_Replay
|
||||
matchInfo->set_length(timeFinished - timeStarted);
|
||||
matchInfo->set_game_name(query1.value(5).toString().toStdString());
|
||||
const QString replayName = query1.value(1).toString();
|
||||
matchInfo->set_do_not_hide(query1.value(6).toBool());
|
||||
|
||||
QSqlQuery query2;
|
||||
query2.prepare("select player_name from cockatrice_games_players where id_game = :id_game");
|
||||
@@ -572,6 +574,22 @@ Response::ResponseCode ServerSocketInterface::cmdReplayDownload(const Command_Re
|
||||
return Response::RespOk;
|
||||
}
|
||||
|
||||
Response::ResponseCode ServerSocketInterface::cmdReplayModifyMatch(const Command_ReplayModifyMatch &cmd, ResponseContainer & /*rc*/)
|
||||
{
|
||||
if (authState != PasswordRight)
|
||||
return Response::RespFunctionNotAllowed;
|
||||
|
||||
QMutexLocker dbLocker(&servatrice->dbMutex);
|
||||
|
||||
QSqlQuery query1;
|
||||
query1.prepare("update " + servatrice->getDbPrefix() + "_replays_access set do_not_hide=:do_not_hide where id_player = :id_player and id_game = :id_game");
|
||||
query1.bindValue(":id_player", userInfo->id());
|
||||
query1.bindValue(":id_game", cmd.game_id());
|
||||
query1.bindValue(":do_not_hide", cmd.do_not_hide());
|
||||
|
||||
return servatrice->execSqlQuery(query1) ? Response::RespOk : Response::RespNameNotFound;
|
||||
}
|
||||
|
||||
|
||||
// MODERATOR FUNCTIONS.
|
||||
// May be called by admins and moderators. Permission is checked by the calling function.
|
||||
|
||||
Reference in New Issue
Block a user