Added official warning messages moderators can use to inform users
This commit is contained in:
parent
1409b97490
commit
6ad2a59367
23 changed files with 429 additions and 7 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include "pb/event_game_joined.pb.h"
|
#include "pb/event_game_joined.pb.h"
|
||||||
#include "pb/serverinfo_user.pb.h"
|
#include "pb/serverinfo_user.pb.h"
|
||||||
#include "pb/serverinfo_room.pb.h"
|
#include "pb/serverinfo_room.pb.h"
|
||||||
|
#include "pb/moderator_commands.pb.h"
|
||||||
|
|
||||||
CloseButton::CloseButton(QWidget *parent)
|
CloseButton::CloseButton(QWidget *parent)
|
||||||
: QAbstractButton(parent)
|
: QAbstractButton(parent)
|
||||||
|
@ -557,8 +558,14 @@ bool TabSupervisor::getAdminLocked() const
|
||||||
|
|
||||||
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ((Event_NotifyUser::NotificationType) event.type()) {
|
switch ((Event_NotifyUser::NotificationType) event.type()) {
|
||||||
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
||||||
|
case Event_NotifyUser::WARNING: {
|
||||||
|
if (!QString::fromStdString(event.warning_reason()).simplified().isEmpty())
|
||||||
|
QMessageBox::warning(this, tr("Warned"), tr("You have received a warning due to %1.\nPlease refrain from engaging in this activity or further actions may be taken against you. If you have any questions, please private message a moderator.").arg(QString::fromStdString(event.warning_reason()).simplified()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
#include <QSignalMapper>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "pb/commands.pb.h"
|
#include "pb/commands.pb.h"
|
||||||
|
@ -23,6 +24,8 @@
|
||||||
#include "pb/response_get_games_of_user.pb.h"
|
#include "pb/response_get_games_of_user.pb.h"
|
||||||
#include "pb/response_get_user_info.pb.h"
|
#include "pb/response_get_user_info.pb.h"
|
||||||
#include "pb/response_ban_history.pb.h"
|
#include "pb/response_ban_history.pb.h"
|
||||||
|
#include "pb/response_warn_history.pb.h"
|
||||||
|
#include "pb/response_warn_list.pb.h"
|
||||||
|
|
||||||
UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *parent, TabGame *_game)
|
UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *parent, TabGame *_game)
|
||||||
: QObject(parent), client(_tabSupervisor->getClient()), tabSupervisor(_tabSupervisor), game(_game)
|
: QObject(parent), client(_tabSupervisor->getClient()), tabSupervisor(_tabSupervisor), game(_game)
|
||||||
|
@ -37,6 +40,8 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p
|
||||||
aAddToIgnoreList = new QAction(QString(), this);
|
aAddToIgnoreList = new QAction(QString(), this);
|
||||||
aRemoveFromIgnoreList = new QAction(QString(), this);
|
aRemoveFromIgnoreList = new QAction(QString(), this);
|
||||||
aKick = new QAction(QString(), this);
|
aKick = new QAction(QString(), this);
|
||||||
|
aWarnUser = new QAction(QString(), this);
|
||||||
|
aWarnHistory = new QAction(QString(), this);
|
||||||
aBan = new QAction(QString(), this);
|
aBan = new QAction(QString(), this);
|
||||||
aBanHistory = new QAction(QString(), this);
|
aBanHistory = new QAction(QString(), this);
|
||||||
aPromoteToMod = new QAction(QString(), this);
|
aPromoteToMod = new QAction(QString(), this);
|
||||||
|
@ -55,6 +60,8 @@ void UserContextMenu::retranslateUi()
|
||||||
aAddToIgnoreList->setText(tr("Add to &ignore list"));
|
aAddToIgnoreList->setText(tr("Add to &ignore list"));
|
||||||
aRemoveFromIgnoreList->setText(tr("Remove from &ignore list"));
|
aRemoveFromIgnoreList->setText(tr("Remove from &ignore list"));
|
||||||
aKick->setText(tr("Kick from &game"));
|
aKick->setText(tr("Kick from &game"));
|
||||||
|
aWarnUser->setText(tr("Warn user"));
|
||||||
|
aWarnHistory->setText(tr("View user's war&n history"));
|
||||||
aBan->setText(tr("Ban from &server"));
|
aBan->setText(tr("Ban from &server"));
|
||||||
aBanHistory->setText(tr("View user's &ban history"));
|
aBanHistory->setText(tr("View user's &ban history"));
|
||||||
aPromoteToMod->setText(tr("&Promote user to moderator"));
|
aPromoteToMod->setText(tr("&Promote user to moderator"));
|
||||||
|
@ -102,6 +109,39 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
||||||
dlg->show();
|
dlg->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::warnUser_processGetWarningsListResponse(const Response &r)
|
||||||
|
{
|
||||||
|
const Response_WarnList &response = r.GetExtension(Response_WarnList::ext);
|
||||||
|
|
||||||
|
QString user = QString::fromStdString(response.user_name()).simplified();
|
||||||
|
QString clientid = QString::fromStdString(response.user_clientid()).simplified();
|
||||||
|
|
||||||
|
// The dialog needs to be non-modal in order to not block the event queue of the client.
|
||||||
|
WarningDialog *dlg = new WarningDialog(user, clientid, static_cast<QWidget *>(parent()));
|
||||||
|
connect(dlg, SIGNAL(accepted()), this, SLOT(warnUser_dialogFinished()));
|
||||||
|
|
||||||
|
if (response.warning_size() > 0) {
|
||||||
|
for (int i = 0; i < response.warning_size(); ++i) {
|
||||||
|
dlg->addWarningOption(QString::fromStdString(response.warning(i)).simplified());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dlg->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::warnUser_processUserInfoResponse(const Response &resp)
|
||||||
|
{
|
||||||
|
const Response_GetUserInfo &response = resp.GetExtension(Response_GetUserInfo::ext);
|
||||||
|
ServerInfo_User userInfo = response.user_info();
|
||||||
|
|
||||||
|
Command_GetWarnList cmd;
|
||||||
|
cmd.set_user_name(userInfo.name());
|
||||||
|
cmd.set_user_clientid(userInfo.clientid());
|
||||||
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
||||||
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(warnUser_processGetWarningsListResponse(Response)));
|
||||||
|
client->sendCommand(pend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void UserContextMenu::banUserHistory_processResponse(const Response &resp) {
|
void UserContextMenu::banUserHistory_processResponse(const Response &resp) {
|
||||||
const Response_BanHistory &response = resp.GetExtension(Response_BanHistory::ext);
|
const Response_BanHistory &response = resp.GetExtension(Response_BanHistory::ext);
|
||||||
if (resp.response_code() == Response::RespOk) {
|
if (resp.response_code() == Response::RespOk) {
|
||||||
|
@ -135,6 +175,38 @@ void UserContextMenu::banUserHistory_processResponse(const Response &resp) {
|
||||||
QMessageBox::critical(static_cast<QWidget *>(parent()), tr("Ban History"), tr("Failed to collecting ban information."));
|
QMessageBox::critical(static_cast<QWidget *>(parent()), tr("Ban History"), tr("Failed to collecting ban information."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::warnUserHistory_processResponse(const Response &resp) {
|
||||||
|
const Response_WarnHistory &response = resp.GetExtension(Response_WarnHistory::ext);
|
||||||
|
if (resp.response_code() == Response::RespOk) {
|
||||||
|
|
||||||
|
if (response.warn_list_size() > 0) {
|
||||||
|
QTableWidget *table = new QTableWidget();
|
||||||
|
table->setWindowTitle(tr("Warning History"));
|
||||||
|
table->setRowCount(response.warn_list_size());
|
||||||
|
table->setColumnCount(4);
|
||||||
|
table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
table->setHorizontalHeaderLabels(
|
||||||
|
QString(tr("Warning Time;Moderator;User Name;Reason")).split(";"));
|
||||||
|
|
||||||
|
ServerInfo_Warning warn; for (int i = 0; i < response.warn_list_size(); ++i) {
|
||||||
|
warn = response.warn_list(i);
|
||||||
|
table->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(warn.time_of())));
|
||||||
|
table->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(warn.admin_name())));
|
||||||
|
table->setItem(i, 2, new QTableWidgetItem(QString::fromStdString(warn.user_name())));
|
||||||
|
table->setItem(i, 3, new QTableWidgetItem(QString::fromStdString(warn.reason())));
|
||||||
|
}
|
||||||
|
|
||||||
|
table->resizeColumnsToContents();
|
||||||
|
table->setMinimumSize(table->horizontalHeader()->length() + (table->columnCount() * 5), table->verticalHeader()->length() + (table->rowCount() * 3));
|
||||||
|
table->show();
|
||||||
|
} else
|
||||||
|
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Warning History"), tr("User has never been warned."));
|
||||||
|
|
||||||
|
} else
|
||||||
|
QMessageBox::critical(static_cast<QWidget *>(parent()), tr("Warning History"), tr("Failed to collecting warning information."));
|
||||||
|
}
|
||||||
|
|
||||||
void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer)
|
void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -171,6 +243,22 @@ void UserContextMenu::banUser_dialogFinished()
|
||||||
client->sendCommand(client->prepareModeratorCommand(cmd));
|
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::warnUser_dialogFinished()
|
||||||
|
{
|
||||||
|
WarningDialog *dlg = static_cast<WarningDialog *>(sender());
|
||||||
|
|
||||||
|
if (dlg->getName().isEmpty() || QString::fromStdString(tabSupervisor->getUserInfo()->name()).simplified().isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Command_WarnUser cmd;
|
||||||
|
cmd.set_user_name(dlg->getName().toStdString());
|
||||||
|
cmd.set_reason(dlg->getReason().toStdString());
|
||||||
|
cmd.set_clientid(dlg->getWarnID().toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, bool online, int playerId)
|
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, bool online, int playerId)
|
||||||
{
|
{
|
||||||
aUserName->setText(userName);
|
aUserName->setText(userName);
|
||||||
|
@ -197,6 +285,9 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
||||||
menu->addAction(aKick);
|
menu->addAction(aKick);
|
||||||
}
|
}
|
||||||
if (!tabSupervisor->getAdminLocked()) {
|
if (!tabSupervisor->getAdminLocked()) {
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(aWarnUser);
|
||||||
|
menu->addAction(aWarnHistory);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(aBan);
|
menu->addAction(aBan);
|
||||||
menu->addAction(aBanHistory);
|
menu->addAction(aBanHistory);
|
||||||
|
@ -218,6 +309,8 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
||||||
aAddToIgnoreList->setEnabled(anotherUser);
|
aAddToIgnoreList->setEnabled(anotherUser);
|
||||||
aRemoveFromIgnoreList->setEnabled(anotherUser);
|
aRemoveFromIgnoreList->setEnabled(anotherUser);
|
||||||
aKick->setEnabled(anotherUser);
|
aKick->setEnabled(anotherUser);
|
||||||
|
aWarnUser->setEnabled(anotherUser);
|
||||||
|
aWarnHistory->setEnabled(anotherUser);
|
||||||
aBan->setEnabled(anotherUser);
|
aBan->setEnabled(anotherUser);
|
||||||
aBanHistory->setEnabled(anotherUser);
|
aBanHistory->setEnabled(anotherUser);
|
||||||
aPromoteToMod->setEnabled(anotherUser);
|
aPromoteToMod->setEnabled(anotherUser);
|
||||||
|
@ -288,6 +381,18 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
||||||
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUserHistory_processResponse(Response)));
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUserHistory_processResponse(Response)));
|
||||||
client->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
|
} else if (actionClicked == aWarnUser) {
|
||||||
|
Command_GetUserInfo cmd;
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(warnUser_processUserInfoResponse(Response)));
|
||||||
|
client->sendCommand(pend);
|
||||||
|
} else if (actionClicked == aWarnHistory) {
|
||||||
|
Command_GetWarnHistory cmd;
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
||||||
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(warnUserHistory_processResponse(Response)));
|
||||||
|
client->sendCommand(pend);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete menu;
|
delete menu;
|
||||||
|
|
|
@ -11,6 +11,7 @@ class QPoint;
|
||||||
class CommandContainer;
|
class CommandContainer;
|
||||||
class Response;
|
class Response;
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
|
class ServerInfo_User;
|
||||||
|
|
||||||
class UserContextMenu : public QObject {
|
class UserContextMenu : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -28,13 +29,18 @@ private:
|
||||||
QAction *aKick;
|
QAction *aKick;
|
||||||
QAction *aBan, *aBanHistory;
|
QAction *aBan, *aBanHistory;
|
||||||
QAction *aPromoteToMod, *aDemoteFromMod;
|
QAction *aPromoteToMod, *aDemoteFromMod;
|
||||||
|
QAction *aWarnUser, *aWarnHistory;
|
||||||
signals:
|
signals:
|
||||||
void openMessageDialog(const QString &userName, bool focus);
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
private slots:
|
private slots:
|
||||||
void banUser_processUserInfoResponse(const Response &resp);
|
void banUser_processUserInfoResponse(const Response &resp);
|
||||||
|
void warnUser_processGetWarningsListResponse(const Response &r);
|
||||||
|
void warnUser_processUserInfoResponse(const Response &resp);
|
||||||
void banUserHistory_processResponse(const Response &resp);
|
void banUserHistory_processResponse(const Response &resp);
|
||||||
|
void warnUserHistory_processResponse(const Response &resp);
|
||||||
void adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer);
|
void adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer);
|
||||||
void banUser_dialogFinished();
|
void banUser_dialogFinished();
|
||||||
|
void warnUser_dialogFinished();
|
||||||
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
||||||
public:
|
public:
|
||||||
UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "pending_command.h"
|
#include "pending_command.h"
|
||||||
#include "pb/session_commands.pb.h"
|
#include "pb/session_commands.pb.h"
|
||||||
#include "pb/moderator_commands.pb.h"
|
#include "pb/moderator_commands.pb.h"
|
||||||
|
@ -116,6 +115,71 @@ BanDialog::BanDialog(const ServerInfo_User &info, QWidget *parent)
|
||||||
setWindowTitle(tr("Ban user from server"));
|
setWindowTitle(tr("Ban user from server"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WarningDialog::WarningDialog(const QString userName, const QString clientID, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
descriptionLabel = new QLabel(tr("Which warning would you like to send?"));
|
||||||
|
nameWarning = new QLineEdit(userName);
|
||||||
|
warnClientID = new QLineEdit(clientID);
|
||||||
|
warningOption = new QComboBox();
|
||||||
|
warningOption->addItem("");
|
||||||
|
|
||||||
|
QPushButton *okButton = new QPushButton(tr("&OK"));
|
||||||
|
okButton->setAutoDefault(true);
|
||||||
|
connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
|
||||||
|
QPushButton *cancelButton = new QPushButton(tr("&Cancel"));
|
||||||
|
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||||
|
buttonLayout->addStretch();
|
||||||
|
buttonLayout->addWidget(okButton);
|
||||||
|
buttonLayout->addWidget(cancelButton);
|
||||||
|
|
||||||
|
QVBoxLayout *vbox = new QVBoxLayout;
|
||||||
|
vbox->addWidget(descriptionLabel);
|
||||||
|
vbox->addWidget(nameWarning);
|
||||||
|
vbox->addWidget(warningOption);
|
||||||
|
vbox->addLayout(buttonLayout);
|
||||||
|
setLayout(vbox);
|
||||||
|
setWindowTitle(tr("Warn user for misconduct"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WarningDialog::okClicked()
|
||||||
|
{
|
||||||
|
if (nameWarning->text().simplified().isEmpty()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("User name to send a warning to can not be blank, please specify a user to warn."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (warningOption->currentText().simplified().isEmpty()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Warning to use can not be blank, please select a valid warning to send."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WarningDialog::getName() const
|
||||||
|
{
|
||||||
|
return nameWarning->text().simplified();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WarningDialog::getWarnID() const
|
||||||
|
{
|
||||||
|
return warnClientID->text().simplified();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WarningDialog::getReason() const
|
||||||
|
{
|
||||||
|
return warningOption->currentText().simplified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WarningDialog::addWarningOption(const QString warning)
|
||||||
|
{
|
||||||
|
warningOption->addItem(warning);
|
||||||
|
}
|
||||||
|
|
||||||
void BanDialog::okClicked()
|
void BanDialog::okClicked()
|
||||||
{
|
{
|
||||||
if (!nameBanCheckBox->isChecked() && !ipBanCheckBox->isChecked() && !idBanCheckBox->isChecked()) {
|
if (!nameBanCheckBox->isChecked() && !ipBanCheckBox->isChecked() && !idBanCheckBox->isChecked()) {
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include "user_level.h"
|
#include "user_level.h"
|
||||||
|
#include "pb/moderator_commands.pb.h"
|
||||||
|
|
||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class ServerInfo_User;
|
class ServerInfo_User;
|
||||||
|
@ -42,6 +44,23 @@ public:
|
||||||
QString getVisibleReason() const;
|
QString getVisibleReason() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WarningDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
QLabel *descriptionLabel;
|
||||||
|
QLineEdit *nameWarning;
|
||||||
|
QComboBox *warningOption;
|
||||||
|
QLineEdit * warnClientID;
|
||||||
|
private slots:
|
||||||
|
void okClicked();
|
||||||
|
public:
|
||||||
|
WarningDialog(const QString userName, const QString clientID, QWidget *parent = 0);
|
||||||
|
QString getName() const;
|
||||||
|
QString getWarnID() const;
|
||||||
|
QString getReason() const;
|
||||||
|
void addWarningOption(const QString warning);
|
||||||
|
};
|
||||||
|
|
||||||
class UserListItemDelegate : public QStyledItemDelegate {
|
class UserListItemDelegate : public QStyledItemDelegate {
|
||||||
public:
|
public:
|
||||||
UserListItemDelegate(QObject *const parent);
|
UserListItemDelegate(QObject *const parent);
|
||||||
|
|
|
@ -12,12 +12,13 @@ QMap<QString, bool> FeatureSet::getDefaultFeatureList() {
|
||||||
return featureList;
|
return featureList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureSet::initalizeFeatureList(QMap<QString, bool> &featureList){
|
void FeatureSet::initalizeFeatureList(QMap<QString, bool> &featureList) {
|
||||||
featureList.insert("client_id", false);
|
featureList.insert("client_id", false);
|
||||||
featureList.insert("client_ver", false);
|
featureList.insert("client_ver", false);
|
||||||
featureList.insert("feature_set", false);
|
featureList.insert("feature_set", false);
|
||||||
featureList.insert("user_ban_history", false);
|
featureList.insert("user_ban_history", false);
|
||||||
featureList.insert("room_chat_history", false);
|
featureList.insert("room_chat_history", false);
|
||||||
|
featureList.insert("client_warnings", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureSet::enableRequiredFeature(QMap<QString, bool> &featureList, QString featureName){
|
void FeatureSet::enableRequiredFeature(QMap<QString, bool> &featureList, QString featureName){
|
||||||
|
|
|
@ -130,6 +130,8 @@ SET(PROTO_FILES
|
||||||
response_replay_download.proto
|
response_replay_download.proto
|
||||||
response_replay_list.proto
|
response_replay_list.proto
|
||||||
response_adjust_mod.proto
|
response_adjust_mod.proto
|
||||||
|
response_warn_history.proto
|
||||||
|
response_warn_list.proto
|
||||||
response.proto
|
response.proto
|
||||||
room_commands.proto
|
room_commands.proto
|
||||||
room_event.proto
|
room_event.proto
|
||||||
|
@ -149,6 +151,7 @@ SET(PROTO_FILES
|
||||||
serverinfo_replay_match.proto
|
serverinfo_replay_match.proto
|
||||||
serverinfo_room.proto
|
serverinfo_room.proto
|
||||||
serverinfo_user.proto
|
serverinfo_user.proto
|
||||||
|
serverinfo_warning.proto
|
||||||
serverinfo_zone.proto
|
serverinfo_zone.proto
|
||||||
server_message.proto
|
server_message.proto
|
||||||
session_commands.proto
|
session_commands.proto
|
||||||
|
|
|
@ -5,11 +5,13 @@ message Event_NotifyUser {
|
||||||
|
|
||||||
enum NotificationType {
|
enum NotificationType {
|
||||||
PROMOTED = 1;
|
PROMOTED = 1;
|
||||||
|
WARNING = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
extend SessionEvent {
|
extend SessionEvent {
|
||||||
optional Event_NotifyUser ext = 1010;
|
optional Event_NotifyUser ext = 1010;
|
||||||
}
|
}
|
||||||
optional NotificationType type = 1;
|
optional NotificationType type = 1;
|
||||||
|
optional string warning_reason = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ message ModeratorCommand {
|
||||||
enum ModeratorCommandType {
|
enum ModeratorCommandType {
|
||||||
BAN_FROM_SERVER = 1000;
|
BAN_FROM_SERVER = 1000;
|
||||||
BAN_HISTORY = 1001;
|
BAN_HISTORY = 1001;
|
||||||
|
WARN_USER = 1002;
|
||||||
|
WARN_HISTORY = 1003;
|
||||||
|
WARN_LIST = 1004;
|
||||||
}
|
}
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
}
|
}
|
||||||
|
@ -24,4 +27,30 @@ message Command_GetBanHistory {
|
||||||
optional Command_GetBanHistory ext = 1001;
|
optional Command_GetBanHistory ext = 1001;
|
||||||
}
|
}
|
||||||
optional string user_name = 1;
|
optional string user_name = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Command_WarnUser {
|
||||||
|
extend ModeratorCommand {
|
||||||
|
optional Command_WarnUser ext = 1002;
|
||||||
|
}
|
||||||
|
|
||||||
|
optional string user_name = 1;
|
||||||
|
optional string reason = 2;
|
||||||
|
optional string clientid = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Command_GetWarnHistory {
|
||||||
|
extend ModeratorCommand {
|
||||||
|
optional Command_GetWarnHistory ext = 1003;
|
||||||
|
}
|
||||||
|
optional string user_name = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Command_GetWarnList {
|
||||||
|
extend ModeratorCommand {
|
||||||
|
optional Command_GetWarnList ext = 1004;
|
||||||
|
}
|
||||||
|
optional string mod_name = 1;
|
||||||
|
optional string user_name = 2;
|
||||||
|
optional string user_clientid = 3;
|
||||||
}
|
}
|
|
@ -53,6 +53,8 @@ message Response {
|
||||||
ACTIVATE = 1010;
|
ACTIVATE = 1010;
|
||||||
ADJUST_MOD = 1011;
|
ADJUST_MOD = 1011;
|
||||||
BAN_HISTORY = 1012;
|
BAN_HISTORY = 1012;
|
||||||
|
WARN_HISTORY = 1013;
|
||||||
|
WARN_LIST = 1014;
|
||||||
REPLAY_LIST = 1100;
|
REPLAY_LIST = 1100;
|
||||||
REPLAY_DOWNLOAD = 1101;
|
REPLAY_DOWNLOAD = 1101;
|
||||||
}
|
}
|
||||||
|
|
10
common/pb/response_warn_history.proto
Normal file
10
common/pb/response_warn_history.proto
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
syntax = "proto2";
|
||||||
|
import "response.proto";
|
||||||
|
import "serverinfo_warning.proto";
|
||||||
|
|
||||||
|
message Response_WarnHistory{
|
||||||
|
extend Response {
|
||||||
|
optional Response_WarnHistory ext = 1013;
|
||||||
|
}
|
||||||
|
repeated ServerInfo_Warning warn_list = 1;
|
||||||
|
}
|
11
common/pb/response_warn_list.proto
Normal file
11
common/pb/response_warn_list.proto
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
syntax = "proto2";
|
||||||
|
import "response.proto";
|
||||||
|
|
||||||
|
message Response_WarnList{
|
||||||
|
extend Response {
|
||||||
|
optional Response_WarnList ext = 1014;
|
||||||
|
}
|
||||||
|
repeated string warning = 1;
|
||||||
|
optional string user_name = 2;
|
||||||
|
optional string user_clientid = 3;
|
||||||
|
}
|
10
common/pb/serverinfo_warning.proto
Normal file
10
common/pb/serverinfo_warning.proto
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
syntax = "proto2";
|
||||||
|
/*
|
||||||
|
* Historical warning information stored in the warnings table
|
||||||
|
*/
|
||||||
|
message ServerInfo_Warning {
|
||||||
|
optional string user_name = 1; // name of user being warned
|
||||||
|
optional string admin_name = 2; // name of the moderator making the warning
|
||||||
|
optional string reason = 3; // type of warning being placed
|
||||||
|
optional string time_of = 4; // time of warning
|
||||||
|
}
|
|
@ -629,4 +629,4 @@ void Server::sendIsl_RoomCommand(const CommandContainer &item, int serverId, qin
|
||||||
cont->set_room_id(roomId);
|
cont->set_room_id(roomId);
|
||||||
|
|
||||||
emit sigSendIslMessage(msg, serverId);
|
emit sigSendIslMessage(msg, serverId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "pb/commands.pb.h"
|
#include "pb/commands.pb.h"
|
||||||
#include "pb/serverinfo_user.pb.h"
|
#include "pb/serverinfo_user.pb.h"
|
||||||
#include "pb/serverinfo_ban.pb.h"
|
#include "pb/serverinfo_ban.pb.h"
|
||||||
|
#include "pb/serverinfo_warning.pb.h"
|
||||||
#include "server_player_reference.h"
|
#include "server_player_reference.h"
|
||||||
|
|
||||||
class Server_DatabaseInterface;
|
class Server_DatabaseInterface;
|
||||||
|
|
13
servatrice/migrations/servatrice_0009_to_0010.sql
Normal file
13
servatrice/migrations/servatrice_0009_to_0010.sql
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
-- Servatrice db migration from version 9 to version 10
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `cockatrice_warnings` (
|
||||||
|
`id` int(7) unsigned NOT NULL,
|
||||||
|
`user_name` varchar(255) NOT NULL,
|
||||||
|
`mod_name` varchar(255) NOT NULL,
|
||||||
|
`reason` text NOT NULL,
|
||||||
|
`time_of` datetime NOT NULL,
|
||||||
|
`clientid` varchar(15) NOT NULL,
|
||||||
|
PRIMARY KEY (`user_name`,`time_of`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
UPDATE cockatrice_schema_version SET version=10 WHERE version=9;
|
|
@ -56,6 +56,11 @@ requireclientid=false
|
||||||
; attempting to log in. Example: "client_id,client_ver"
|
; attempting to log in. Example: "client_id,client_ver"
|
||||||
requiredfeatures=""
|
requiredfeatures=""
|
||||||
|
|
||||||
|
; You can define custom warnings that users are sent when the moderation staff uses the right client warn user
|
||||||
|
; menu option. This list is comma seperated that each item will appear in the drop down list for staff members
|
||||||
|
; to choose from. Example: "Flaming,Foul Language"
|
||||||
|
officialwarnings="Flamming,Spamming,Causing Drama,Abusive Language"
|
||||||
|
|
||||||
[authentication]
|
[authentication]
|
||||||
|
|
||||||
; Servatrice can authenticate users connecting. It currently supports 3 different authentication methods:
|
; Servatrice can authenticate users connecting. It currently supports 3 different authentication methods:
|
||||||
|
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
|
||||||
PRIMARY KEY (`version`)
|
PRIMARY KEY (`version`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
INSERT INTO cockatrice_schema_version VALUES(8);
|
INSERT INTO cockatrice_schema_version VALUES(10);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
||||||
`id` int(7) unsigned zerofill NOT NULL auto_increment,
|
`id` int(7) unsigned zerofill NOT NULL auto_increment,
|
||||||
|
@ -138,6 +138,16 @@ CREATE TABLE IF NOT EXISTS `cockatrice_bans` (
|
||||||
KEY `ip_address` (`ip_address`)
|
KEY `ip_address` (`ip_address`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `cockatrice_warnings` (
|
||||||
|
`id` int(7) unsigned NOT NULL,
|
||||||
|
`user_name` varchar(255) NOT NULL,
|
||||||
|
`mod_name` varchar(255) NOT NULL
|
||||||
|
`reason` text NOT NULL,
|
||||||
|
`time_of` datetime NOT NULL,
|
||||||
|
`clientid` varchar(15) NOT NULL,
|
||||||
|
PRIMARY KEY (`user_name`,`time_of`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `cockatrice_sessions` (
|
CREATE TABLE IF NOT EXISTS `cockatrice_sessions` (
|
||||||
`id` int(9) NOT NULL AUTO_INCREMENT,
|
`id` int(9) NOT NULL AUTO_INCREMENT,
|
||||||
`user_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
`user_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||||
|
|
|
@ -113,6 +113,7 @@ private:
|
||||||
QString dbPrefix;
|
QString dbPrefix;
|
||||||
QString requiredFeatures;
|
QString requiredFeatures;
|
||||||
QMap<QString, bool> serverRequiredFeatureList;
|
QMap<QString, bool> serverRequiredFeatureList;
|
||||||
|
QString officialWarnings;
|
||||||
Servatrice_DatabaseInterface *servatriceDatabaseInterface;
|
Servatrice_DatabaseInterface *servatriceDatabaseInterface;
|
||||||
int serverId;
|
int serverId;
|
||||||
int uptime;
|
int uptime;
|
||||||
|
@ -139,6 +140,7 @@ public:
|
||||||
~Servatrice();
|
~Servatrice();
|
||||||
bool initServer();
|
bool initServer();
|
||||||
QMap<QString, bool> getServerRequiredFeatureList() const { return serverRequiredFeatureList; }
|
QMap<QString, bool> getServerRequiredFeatureList() const { return serverRequiredFeatureList; }
|
||||||
|
QString getOfficialWarningsList() const { return officialWarnings; }
|
||||||
QString getServerName() const { return serverName; }
|
QString getServerName() const { return serverName; }
|
||||||
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
|
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
|
||||||
QString getRequiredFeatures() const { return requiredFeatures; }
|
QString getRequiredFeatures() const { return requiredFeatures; }
|
||||||
|
|
|
@ -940,7 +940,7 @@ QList<ServerInfo_Ban> Servatrice_DatabaseInterface::getUserBanHistory(const QStr
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString adminID,adminName,banTime,banLength,banReason,visibleReason;
|
//QString adminID,adminName,banTime,banLength,banReason,visibleReason;
|
||||||
while (query->next()){
|
while (query->next()){
|
||||||
banDetails.set_admin_id(QString(query->value(0).toString()).toStdString());
|
banDetails.set_admin_id(QString(query->value(0).toString()).toStdString());
|
||||||
banDetails.set_admin_name(QString(query->value(5).toString()).toStdString());
|
banDetails.set_admin_name(QString(query->value(5).toString()).toStdString());
|
||||||
|
@ -953,3 +953,51 @@ QList<ServerInfo_Ban> Servatrice_DatabaseInterface::getUserBanHistory(const QStr
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Servatrice_DatabaseInterface::addWarning(const QString userName, const QString adminName, const QString warningReason, const QString clientID)
|
||||||
|
{
|
||||||
|
if (!checkSql())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int userID = getUserIdInDB(userName);
|
||||||
|
QSqlQuery *query = prepareQuery("insert into {prefix}_warnings (id,user_name,mod_name,reason,time_of,clientid) values (:user_id,:user_name,:mod_name,:warn_reason,NOW(),:client_id)");
|
||||||
|
query->bindValue(":user_id", userID);
|
||||||
|
query->bindValue(":user_name", userName);
|
||||||
|
query->bindValue(":mod_name", adminName);
|
||||||
|
query->bindValue(":warn_reason", warningReason);
|
||||||
|
query->bindValue(":client_id", clientID);
|
||||||
|
if (!execSqlQuery(query)) {
|
||||||
|
qDebug("Failed to collect create warning history information: SQL Error");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<ServerInfo_Warning> Servatrice_DatabaseInterface::getUserWarnHistory(const QString userName)
|
||||||
|
{
|
||||||
|
QList<ServerInfo_Warning> results;
|
||||||
|
ServerInfo_Warning warnDetails;
|
||||||
|
|
||||||
|
if (!checkSql())
|
||||||
|
return results;
|
||||||
|
|
||||||
|
int userID = getUserIdInDB(userName);
|
||||||
|
QSqlQuery *query = prepareQuery("SELECT user_name, mod_name, reason, time_of FROM {prefix}_warnings WHERE id = :user_id");
|
||||||
|
query->bindValue(":user_id", userID);
|
||||||
|
|
||||||
|
if (!execSqlQuery(query)) {
|
||||||
|
qDebug("Failed to collect warning history information: SQL Error");
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (query->next()){
|
||||||
|
warnDetails.set_user_name(QString(query->value(0).toString()).toStdString());
|
||||||
|
warnDetails.set_admin_name(QString(query->value(1).toString()).toStdString());
|
||||||
|
warnDetails.set_reason(QString(query->value(2).toString()).toStdString());
|
||||||
|
warnDetails.set_time_of(QString(query->value(3).toString()).toStdString());
|
||||||
|
results << warnDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "server_database_interface.h"
|
#include "server_database_interface.h"
|
||||||
|
|
||||||
#define DATABASE_SCHEMA_VERSION 9
|
#define DATABASE_SCHEMA_VERSION 10
|
||||||
|
|
||||||
class Servatrice;
|
class Servatrice;
|
||||||
|
|
||||||
|
@ -79,6 +79,8 @@ public:
|
||||||
bool changeUserPassword(const QString &user, const QString &oldPassword, const QString &newPassword);
|
bool changeUserPassword(const QString &user, const QString &oldPassword, const QString &newPassword);
|
||||||
QChar getGenderChar(ServerInfo_User_Gender const &gender);
|
QChar getGenderChar(ServerInfo_User_Gender const &gender);
|
||||||
QList<ServerInfo_Ban> getUserBanHistory(const QString userName);
|
QList<ServerInfo_Ban> getUserBanHistory(const QString userName);
|
||||||
|
bool addWarning(const QString userName, const QString adminName, const QString warningReason, const QString clientID);
|
||||||
|
QList<ServerInfo_Warning> getUserWarnHistory(const QString userName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -59,6 +59,8 @@
|
||||||
#include "pb/response_register.pb.h"
|
#include "pb/response_register.pb.h"
|
||||||
#include "pb/response_replay_list.pb.h"
|
#include "pb/response_replay_list.pb.h"
|
||||||
#include "pb/response_replay_download.pb.h"
|
#include "pb/response_replay_download.pb.h"
|
||||||
|
#include "pb/response_warn_history.pb.h"
|
||||||
|
#include "pb/response_warn_list.pb.h"
|
||||||
#include "pb/serverinfo_replay.pb.h"
|
#include "pb/serverinfo_replay.pb.h"
|
||||||
#include "pb/serverinfo_user.pb.h"
|
#include "pb/serverinfo_user.pb.h"
|
||||||
#include "pb/serverinfo_deckstorage.pb.h"
|
#include "pb/serverinfo_deckstorage.pb.h"
|
||||||
|
@ -305,6 +307,9 @@ Response::ResponseCode ServerSocketInterface::processExtendedModeratorCommand(in
|
||||||
switch ((ModeratorCommand::ModeratorCommandType) cmdType) {
|
switch ((ModeratorCommand::ModeratorCommandType) cmdType) {
|
||||||
case ModeratorCommand::BAN_FROM_SERVER: return cmdBanFromServer(cmd.GetExtension(Command_BanFromServer::ext), rc);
|
case ModeratorCommand::BAN_FROM_SERVER: return cmdBanFromServer(cmd.GetExtension(Command_BanFromServer::ext), rc);
|
||||||
case ModeratorCommand::BAN_HISTORY: return cmdGetBanHistory(cmd.GetExtension(Command_GetBanHistory::ext), rc);
|
case ModeratorCommand::BAN_HISTORY: return cmdGetBanHistory(cmd.GetExtension(Command_GetBanHistory::ext), rc);
|
||||||
|
case ModeratorCommand::WARN_USER: return cmdWarnUser(cmd.GetExtension(Command_WarnUser::ext), rc);
|
||||||
|
case ModeratorCommand::WARN_HISTORY: return cmdGetWarnHistory(cmd.GetExtension(Command_GetWarnHistory::ext), rc);
|
||||||
|
case ModeratorCommand::WARN_LIST: return cmdGetWarnList(cmd.GetExtension(Command_GetWarnList::ext), rc);
|
||||||
default: return Response::RespFunctionNotAllowed;
|
default: return Response::RespFunctionNotAllowed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -779,6 +784,70 @@ Response::ResponseCode ServerSocketInterface::cmdGetBanHistory(const Command_Get
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Response::ResponseCode ServerSocketInterface::cmdGetWarnList(const Command_GetWarnList &cmd, ResponseContainer &rc)
|
||||||
|
{
|
||||||
|
Response_WarnList *re = new Response_WarnList;
|
||||||
|
|
||||||
|
QString officialWarnings = settingsCache->value("server/officialwarnings").toString();
|
||||||
|
QStringList warningsList = officialWarnings.split(",", QString::SkipEmptyParts);
|
||||||
|
foreach(QString warning, warningsList){
|
||||||
|
re->add_warning(warning.toStdString());
|
||||||
|
}
|
||||||
|
re->set_user_name(cmd.user_name());
|
||||||
|
re->set_user_clientid(cmd.user_clientid());
|
||||||
|
rc.setResponseExtension(re);
|
||||||
|
return Response::RespOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
Response::ResponseCode ServerSocketInterface::cmdGetWarnHistory(const Command_GetWarnHistory &cmd, ResponseContainer &rc)
|
||||||
|
{
|
||||||
|
QList<ServerInfo_Warning> warnList;
|
||||||
|
QString userName = QString::fromStdString(cmd.user_name());
|
||||||
|
|
||||||
|
Response_WarnHistory *re = new Response_WarnHistory;
|
||||||
|
QListIterator<ServerInfo_Warning> warnIterator(sqlInterface->getUserWarnHistory(userName));
|
||||||
|
while (warnIterator.hasNext())
|
||||||
|
re->add_warn_list()->CopyFrom(warnIterator.next());
|
||||||
|
rc.setResponseExtension(re);
|
||||||
|
return Response::RespOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
Response::ResponseCode ServerSocketInterface::cmdWarnUser(const Command_WarnUser &cmd, ResponseContainer & /*rc*/)
|
||||||
|
{
|
||||||
|
if (!sqlInterface->checkSql())
|
||||||
|
return Response::RespInternalError;
|
||||||
|
|
||||||
|
QString userName = QString::fromStdString(cmd.user_name()).simplified();
|
||||||
|
QString warningReason = QString::fromStdString(cmd.reason()).simplified();
|
||||||
|
QString clientID = QString::fromStdString(cmd.clientid()).simplified();
|
||||||
|
QString sendingModerator = QString::fromStdString(userInfo->name()).simplified();
|
||||||
|
|
||||||
|
if (sqlInterface->addWarning(userName, sendingModerator, warningReason, clientID)) {
|
||||||
|
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
|
||||||
|
if (user) {
|
||||||
|
Event_NotifyUser event;
|
||||||
|
event.set_type(Event_NotifyUser::WARNING);
|
||||||
|
event.set_warning_reason(cmd.reason());
|
||||||
|
SessionEvent *se = user->prepareSessionEvent(event);
|
||||||
|
user->sendProtocolItem(*se);
|
||||||
|
delete se;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QString> moderatorList = server->getOnlineModeratorList();
|
||||||
|
QListIterator<QString> modIterator(moderatorList);
|
||||||
|
foreach(QString moderator, moderatorList) {
|
||||||
|
QString notificationMessage = sendingModerator + " has sent a warning with the following information";
|
||||||
|
notificationMessage.append("\n Username: " + userName);
|
||||||
|
notificationMessage.append("\n Reason: " + warningReason);
|
||||||
|
sendServerMessage(moderator.simplified(), notificationMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::RespOk;
|
||||||
|
} else {
|
||||||
|
return Response::RespInternalError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_BanFromServer &cmd, ResponseContainer & /*rc*/)
|
Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_BanFromServer &cmd, ResponseContainer & /*rc*/)
|
||||||
{
|
{
|
||||||
if (!sqlInterface->checkSql())
|
if (!sqlInterface->checkSql())
|
||||||
|
@ -850,7 +919,7 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
||||||
QList<QString> moderatorList = server->getOnlineModeratorList();
|
QList<QString> moderatorList = server->getOnlineModeratorList();
|
||||||
QListIterator<QString> modIterator(moderatorList);
|
QListIterator<QString> modIterator(moderatorList);
|
||||||
foreach(QString moderator, moderatorList) {
|
foreach(QString moderator, moderatorList) {
|
||||||
QString notificationMessage = "A ban has been added:";
|
QString notificationMessage = QString::fromStdString(userInfo->name()).simplified() + " has placed a ban with the following information";
|
||||||
if (!userName.isEmpty())
|
if (!userName.isEmpty())
|
||||||
notificationMessage.append("\n Username: " + userName);
|
notificationMessage.append("\n Username: " + userName);
|
||||||
if (!address.isEmpty())
|
if (!address.isEmpty())
|
||||||
|
|
|
@ -97,7 +97,10 @@ private:
|
||||||
Response::ResponseCode cmdReplayModifyMatch(const Command_ReplayModifyMatch &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdReplayModifyMatch(const Command_ReplayModifyMatch &cmd, ResponseContainer &rc);
|
||||||
Response::ResponseCode cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer &rc);
|
||||||
Response::ResponseCode cmdBanFromServer(const Command_BanFromServer &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdBanFromServer(const Command_BanFromServer &cmd, ResponseContainer &rc);
|
||||||
|
Response::ResponseCode cmdWarnUser(const Command_WarnUser &cmd, ResponseContainer &rc);
|
||||||
Response::ResponseCode cmdGetBanHistory(const Command_GetBanHistory &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdGetBanHistory(const Command_GetBanHistory &cmd, ResponseContainer &rc);
|
||||||
|
Response::ResponseCode cmdGetWarnList(const Command_GetWarnList &cmd, ResponseContainer &rc);
|
||||||
|
Response::ResponseCode cmdGetWarnHistory(const Command_GetWarnHistory &cmd, ResponseContainer &rc);
|
||||||
Response::ResponseCode cmdShutdownServer(const Command_ShutdownServer &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdShutdownServer(const Command_ShutdownServer &cmd, ResponseContainer &rc);
|
||||||
Response::ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage &cmd, ResponseContainer &rc);
|
||||||
Response::ResponseCode cmdRegisterAccount(const Command_Register &cmd, ResponseContainer &rc);
|
Response::ResponseCode cmdRegisterAccount(const Command_Register &cmd, ResponseContainer &rc);
|
||||||
|
|
Loading…
Reference in a new issue