Fixed offline messages bug

This commit is contained in:
WolverinDEV 2020-05-09 16:55:15 +02:00
parent 9ef9ce2b22
commit 885cf52bdc
3 changed files with 36 additions and 29 deletions

@ -1 +1 @@
Subproject commit 7261d531f3c10be1437a4572369260aeff075e6c Subproject commit 99293e3af97cdc4041282a29495841b8ae3d2a4d

View File

@ -44,11 +44,10 @@ extern void testTomMath();
#define DB_NAME "TeaData.sqlite" #define DB_NAME "TeaData.sqlite"
#endif #endif
#include <regex>
#include <codecvt> #include <codecvt>
#include "src/client/music/internal_provider/channel_replay/ChannelProvider.h" #include "src/client/music/internal_provider/channel_replay/ChannelProvider.h"
class CLIParser{ class CLIParser {
public: public:
CLIParser (int &argc, char **argv){ CLIParser (int &argc, char **argv){
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)

View File

@ -44,7 +44,7 @@ if(!result && result.msg().find(ignore) == string::npos){
#define RESIZE_COLUMN(tblName, rowName, size) up vote EXECUTE("Could not change column size", "ALTER TABLE " tblName " ALTER COLUMN " rowName " varchar(" size ")"); #define RESIZE_COLUMN(tblName, rowName, size) up vote EXECUTE("Could not change column size", "ALTER TABLE " tblName " ALTER COLUMN " rowName " varchar(" size ")");
#define CURRENT_DATABASE_VERSION 11 #define CURRENT_DATABASE_VERSION 12
#define CURRENT_PERMISSION_VERSION 4 #define CURRENT_PERMISSION_VERSION 4
#define CLIENT_UID_LENGTH "64" #define CLIENT_UID_LENGTH "64"
@ -271,38 +271,38 @@ bool SqlDataManager::update_database(std::string &error) {
case 7: case 7:
/* recreate permission table */ /* recreate permission table */
/* /*
DROP TABLE `permissions`, `properties`; DROP TABLE `permissions`, `properties`;
ALTER TABLE permissions_v6 RENAME permissions; ALTER TABLE permissions_v6 RENAME permissions;
ALTER TABLE properties_v6 RENAME properties; ALTER TABLE properties_v6 RENAME properties;
*/ */
/* MySQL command /* MySQL command
START TRANSACTION; START TRANSACTION;
SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
-- Modify the permissions -- Modify the permissions
ALTER TABLE permissions RENAME TO permissions_v6; ALTER TABLE permissions RENAME TO permissions_v6;
CREATE TABLE `permissions`(`serverId` INT NOT NULL, `type` INT, `id` INT, `channelId` INT, `permId` VARCHAR(256), `value` INT, `grant` INT, `flag_skip` TINYINT(1), `flag_negate` TINYINT(1), CONSTRAINT PK PRIMARY KEY(`serverId`, `type`, `id`, `channelId`, `permId`)) CHARACTER SET=utf8; CREATE TABLE `permissions`(`serverId` INT NOT NULL, `type` INT, `id` INT, `channelId` INT, `permId` VARCHAR(256), `value` INT, `grant` INT, `flag_skip` TINYINT(1), `flag_negate` TINYINT(1), CONSTRAINT PK PRIMARY KEY(`serverId`, `type`, `id`, `channelId`, `permId`)) CHARACTER SET=utf8;
CREATE INDEX `idx_permissions_serverId` ON `permissions` (`serverId`); CREATE INDEX `idx_permissions_serverId` ON `permissions` (`serverId`);
CREATE INDEX `idx_permissions_serverId_channelId` ON `permissions` (`serverId`, `channelId`); CREATE INDEX `idx_permissions_serverId_channelId` ON `permissions` (`serverId`, `channelId`);
INSERT INTO `permissions` SELECT * FROM `permissions_v6` GROUP BY `serverId`, `type`, `id`, `channelId`, `permId`; INSERT INTO `permissions` SELECT * FROM `permissions_v6` GROUP BY `serverId`, `type`, `id`, `channelId`, `permId`;
-- Modify the properties -- Modify the properties
ALTER TABLE properties RENAME TO properties_v6; ALTER TABLE properties RENAME TO properties_v6;
CREATE TABLE properties(`serverId` INTEGER DEFAULT -1, `type` INTEGER, `id` INTEGER, `key` VARCHAR(256), `value` TEXT, CONSTRAINT PK PRIMARY KEY (`serverId`, `type`, `id`, `key`)) CHARACTER SET=utf8; CREATE TABLE properties(`serverId` INTEGER DEFAULT -1, `type` INTEGER, `id` INTEGER, `key` VARCHAR(256), `value` TEXT, CONSTRAINT PK PRIMARY KEY (`serverId`, `type`, `id`, `key`)) CHARACTER SET=utf8;
CREATE INDEX `idx_properties_serverId` ON `properties` (`serverId`); CREATE INDEX `idx_properties_serverId` ON `properties` (`serverId`);
CREATE INDEX `idx_properties_serverId_id` ON `properties` (`serverId`, `id`); CREATE INDEX `idx_properties_serverId_id` ON `properties` (`serverId`, `id`);
INSERT INTO `properties` SELECT * FROM `properties_v6` GROUP BY `serverId`, `type`, `id`, `key`; INSERT INTO `properties` SELECT * FROM `properties_v6` GROUP BY `serverId`, `type`, `id`, `key`;
-- Delete orphaned permissions and properties -- Delete orphaned permissions and properties
DELETE FROM `permissions` WHERE (`type` = 1 OR `type` = 2) AND NOT ((`serverId`, `channelId`) IN (SELECT `serverId`, `channelId` FROM `channels`) OR `channelId` = 0); DELETE FROM `permissions` WHERE (`type` = 1 OR `type` = 2) AND NOT ((`serverId`, `channelId`) IN (SELECT `serverId`, `channelId` FROM `channels`) OR `channelId` = 0);
DELETE FROM `permissions` WHERE `type` = 0 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `groupId` FROM `groups`); DELETE FROM `permissions` WHERE `type` = 0 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `groupId` FROM `groups`);
DELETE FROM `permissions` WHERE `type` = 2 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `cldbid` FROM `clients`); DELETE FROM `permissions` WHERE `type` = 2 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `cldbid` FROM `clients`);
DELETE FROM `properties` WHERE `type` = 1 AND NOT (`serverId` IN (SELECT `serverId` FROM servers) OR `serverId` = 0); DELETE FROM `properties` WHERE `type` = 1 AND NOT (`serverId` IN (SELECT `serverId` FROM servers) OR `serverId` = 0);
ROLLBACK; ROLLBACK;
*/ */
if(manager->getType() == sql::TYPE_MYSQL) { if(manager->getType() == sql::TYPE_MYSQL) {
/* /*
@ -477,6 +477,14 @@ ROLLBACK;
} }
db_version(12); db_version(12);
#endif #endif
case 11:
result = sql::command(this->sql(), "UPDATE TABLE `letters` SET `created` TO 0 WHERE 1;").execute();
if(!result) {
error = "Failed to reset offline messages timestamps";
return false;
}
db_version(12);
default: default:
break; break;
} }