Compare commits

..

263 Commits

Author SHA1 Message Date
75ad07477a Merge pull request '1.0.0' (#253) from 1.0.0 into master
Reviewed-on: sh-edraft.de/kd_discord_bot#253
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
2023-03-27 09:30:49 +02:00
132d41f0a2 Fixed some stuff 2023-03-26 22:58:56 +02:00
707a835672 Updated docker & config 2023-03-26 20:08:04 +02:00
f56dbf8e2a Merge pull request 'Fixed permission handling for member data #256' (#258) from #256 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#258
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
#Closes #256
2023-03-25 18:01:57 +01:00
c311e534d7 Merge pull request 'Fixed profile navigation #255' (#257) from #255 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#257
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #255
2023-03-25 18:01:41 +01:00
87b277515c Fixed permission handling for member data #256 2023-03-24 14:23:13 +01:00
e6c614dfdc Fixed profile navigation #255 2023-03-24 14:15:21 +01:00
24d5bbf4d8 Made version in presence optional 2023-03-24 14:14:49 +01:00
52035af0cc Fixed jwt handling 2023-03-21 19:14:39 +01:00
fdc9a118c8 Fixed jwt handling 2023-03-20 16:30:07 +01:00
ba1f4ee955 Merge pull request '1.0.0-fix' (#254) from 1.0.0-fix into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#254
2023-03-20 14:41:33 +01:00
35d161c080 Removed obsolete fix 2023-03-20 14:40:56 +01:00
818163cbed Formatted tools 2023-03-20 14:39:23 +01:00
468ebb5f79 Merge branch 'master' into 1.0.0-fix
# Conflicts:
#	kdb-bot/src/bot/__init__.py
#	kdb-bot/src/bot/bot.json
#	kdb-bot/src/bot/config
#	kdb-bot/src/bot/extension/__init__.py
#	kdb-bot/src/bot_api/__init__.py
#	kdb-bot/src/bot_api/abc/__init__.py
#	kdb-bot/src/bot_api/bot-api.json
#	kdb-bot/src/bot_api/configuration/__init__.py
#	kdb-bot/src/bot_api/controller/__init__.py
#	kdb-bot/src/bot_api/event/__init__.py
#	kdb-bot/src/bot_api/exception/__init__.py
#	kdb-bot/src/bot_api/filter/__init__.py
#	kdb-bot/src/bot_api/filter/discord/__init__.py
#	kdb-bot/src/bot_api/logging/__init__.py
#	kdb-bot/src/bot_api/model/__init__.py
#	kdb-bot/src/bot_api/model/discord/__init__.py
#	kdb-bot/src/bot_api/route/__init__.py
#	kdb-bot/src/bot_api/service/__init__.py
#	kdb-bot/src/bot_api/transformer/__init__.py
#	kdb-bot/src/bot_core/__init__.py
#	kdb-bot/src/bot_core/abc/__init__.py
#	kdb-bot/src/bot_core/bot-core.json
#	kdb-bot/src/bot_core/configuration/__init__.py
#	kdb-bot/src/bot_core/core_extension/__init__.py
#	kdb-bot/src/bot_core/events/__init__.py
#	kdb-bot/src/bot_core/exception/__init__.py
#	kdb-bot/src/bot_core/helper/__init__.py
#	kdb-bot/src/bot_core/logging/__init__.py
#	kdb-bot/src/bot_core/pipes/__init__.py
#	kdb-bot/src/bot_core/service/__init__.py
#	kdb-bot/src/bot_data/__init__.py
#	kdb-bot/src/bot_data/abc/__init__.py
#	kdb-bot/src/bot_data/bot-data.json
#	kdb-bot/src/bot_data/migration/__init__.py
#	kdb-bot/src/bot_data/model/__init__.py
#	kdb-bot/src/bot_data/service/__init__.py
#	kdb-bot/src/bot_graphql/__init__.py
#	kdb-bot/src/bot_graphql/abc/__init__.py
#	kdb-bot/src/bot_graphql/filter/__init__.py
#	kdb-bot/src/bot_graphql/mutations/__init__.py
#	kdb-bot/src/modules/auto_role/__init__.py
#	kdb-bot/src/modules/auto_role/auto-role.json
#	kdb-bot/src/modules/auto_role/command/__init__.py
#	kdb-bot/src/modules/auto_role/events/__init__.py
#	kdb-bot/src/modules/auto_role/helper/__init__.py
#	kdb-bot/src/modules/base/__init__.py
#	kdb-bot/src/modules/base/abc/__init__.py
#	kdb-bot/src/modules/base/base.json
#	kdb-bot/src/modules/base/command/__init__.py
#	kdb-bot/src/modules/base/configuration/__init__.py
#	kdb-bot/src/modules/base/events/__init__.py
#	kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py
#	kdb-bot/src/modules/base/helper/__init__.py
#	kdb-bot/src/modules/base/model/__init__.py
#	kdb-bot/src/modules/base/service/__init__.py
#	kdb-bot/src/modules/base/thread/__init__.py
#	kdb-bot/src/modules/boot_log/__init__.py
#	kdb-bot/src/modules/boot_log/boot-log.json
#	kdb-bot/src/modules/boot_log/configuration/__init__.py
#	kdb-bot/src/modules/database/__init__.py
#	kdb-bot/src/modules/database/database.json
#	kdb-bot/src/modules/level/__init__.py
#	kdb-bot/src/modules/level/command/__init__.py
#	kdb-bot/src/modules/level/configuration/__init__.py
#	kdb-bot/src/modules/level/events/__init__.py
#	kdb-bot/src/modules/level/level.json
#	kdb-bot/src/modules/level/service/__init__.py
#	kdb-bot/src/modules/permission/__init__.py
#	kdb-bot/src/modules/permission/abc/__init__.py
#	kdb-bot/src/modules/permission/configuration/__init__.py
#	kdb-bot/src/modules/permission/events/__init__.py
#	kdb-bot/src/modules/permission/permission.json
#	kdb-bot/src/modules/permission/service/__init__.py
#	kdb-bot/src/modules/stats/service/__init__.py
#	kdb-bot/src/modules/stats/stats.json
#	kdb-bot/src/modules/technician/__init__.py
#	kdb-bot/src/modules/technician/command/__init__.py
#	kdb-bot/src/modules/technician/technician.json
#	kdb-bot/tools/get_version/get-version.json
#	kdb-bot/tools/post_build/post-build.json
#	kdb-bot/tools/set_version/set-version.json
2023-03-20 14:39:18 +01:00
085726bf60 Updated config 2023-03-20 14:32:44 +01:00
223abbe66f Fixed user mutation 2023-03-20 14:11:02 +01:00
4c5a8baed5 Build release 2023-03-20 14:01:08 +01:00
59162408e5 Merge pull request 'Datenschutz und Impressum angeben #251' (#252) from #251 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#252
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #251
2023-03-20 13:42:23 +01:00
634b81d23b Merge branch '1.0.0' into #251 2023-03-20 13:40:17 +01:00
c0cd5bb70e Merge pull request '1.0.0.rc2' (#250) from 1.0.0.rc2 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#250
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
2023-03-20 13:40:00 +01:00
cc0a0a5c69 Added logic to confirm privacy before registration #251 2023-03-17 14:43:16 +01:00
4420c0e11c Added imprint & privacy to auth and improved getting url #251 2023-03-17 13:48:48 +01:00
7be40ed236 Added imprint and privacy urls 2023-03-17 13:18:33 +01:00
ff415c354d Merge branch '1.0.0' into 1.0.0.rc2 2023-03-14 18:43:35 +01:00
283eaabef6 Merge pull request 'Als Nutzer möchte ich Datenänderungen nach verfolgen können #246' (#248) from #246 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#248
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Reviewed-by: Jonas <joni.drescher@web.de>
2023-03-14 18:31:36 +01:00
b7e72888f7 Fixed translation #246 2023-03-14 17:00:52 +01:00
b29227e8d5 Fixed translation 2023-03-14 17:00:34 +01:00
9f57182fc1 Fixed collection sorting & paging order 2023-03-14 15:32:26 +01:00
699377be54 Added type hints #246 2023-03-14 15:32:00 +01:00
efba1a4ce8 Added type hints #246 2023-03-12 18:46:39 +01:00
68fa1b8c2d Fixed translation 2023-03-12 05:04:26 +01:00
8b79d69e41 Build 1.0.0.rc2 2023-03-12 04:55:42 +01:00
c1b75dff78 Set frontent version 1.0.0.rc2 2023-03-12 04:55:42 +01:00
5f284597aa Build 1.0.0.rc2 2023-03-12 04:55:42 +01:00
e1b1a68b07 Set version for rc2 2023-03-12 04:55:42 +01:00
b1a0115e8b Fixed db set date & show only changed fields in history view #246 2023-03-12 04:55:04 +01:00
ad00dce5d9 Fixed mysql scripts #246 2023-03-11 03:09:27 +01:00
e3c47ce5b1 Fixed mysql scripts #246 2023-03-11 03:09:18 +01:00
68026e4b47 Improved history component #246 2023-03-11 03:08:47 +01:00
ee503f76f2 Order history tables #246 2023-03-11 01:19:06 +01:00
a1f7b8b2dc Added en and fixed de translation #246 2023-03-11 01:19:06 +01:00
b8e4146b33 Added history to all data tables #246 2023-03-11 01:19:06 +01:00
51f0ee5744 Improved history component #246 2023-03-11 01:19:06 +01:00
69ce659328 Added history tables to graphql #246 2023-03-11 01:18:35 +01:00
325a17b5a8 Added level history to graphql #246 2023-03-11 01:18:35 +01:00
5df0501505 Added last migration parts #246 2023-03-11 01:18:35 +01:00
c3ef7a746f [WIP] Added last tables #246 2023-03-11 01:18:35 +01:00
bca33c6e56 [WIP] Added more tables #246 2023-03-11 01:18:35 +01:00
d24d3fa4de [WIP] Added more tables #246 2023-03-11 01:18:35 +01:00
1755efb5d9 [WIP] Added migration and basics for history logic #246 2023-03-11 01:18:35 +01:00
54b0086a14 Merge pull request 'Unbekannte Benutzer führen zu einem Fehler mit tracking id statt einer fehlermeldung #247' (#249) from #247 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#249
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #247
2023-03-11 01:17:15 +01:00
f404287cc1 Merge branch '1.0.0' into #247 2023-03-11 01:14:47 +01:00
7966ca16e5 Merge pull request '1.0.0.rc1' (#244) from 1.0.0.rc1 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#244
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
2023-03-11 01:12:31 +01:00
c0e5f0d4b0 Updated config 2023-03-09 19:41:10 +01:00
80769a1bf0 Fixed permission service 2023-03-09 19:27:56 +01:00
bc92dc4536 Fixed icon buttons #247 2023-03-09 11:22:10 +01:00
16ef29999c Fixed _is_email_valid method #247 2023-03-09 11:15:28 +01:00
33279b7053 Fixed collection count field #247 2023-03-09 11:12:48 +01:00
04fcfddbd9 Code cleanup #247 2023-03-09 11:10:53 +01:00
21f0f32322 Retranslate sidebar on lang change 2023-03-06 10:54:58 +01:00
d1420d18c0 Put boot log send message in loop task #243 2023-03-06 10:54:58 +01:00
22d26bf032 Reload levelsystem after mutate levels #245 2023-03-06 10:54:58 +01:00
a701807831 Fixed frontend permissions 2023-03-06 10:54:58 +01:00
3324cf3ac3 Fixed time calculation for user joined gs/vs 2023-03-06 10:54:58 +01:00
1664c67763 Fixed time calculation for user joined gs/vs 2023-03-06 10:54:58 +01:00
bddcd3929a Updated docker compose 2023-03-06 10:54:58 +01:00
23e17c1f38 Fixed auto-role error 2023-03-06 08:42:48 +01:00
883811d156 Removed minecraft_id 2023-03-06 08:42:48 +01:00
4d0e8898fe Build frontend 2023-03-06 08:42:48 +01:00
505c87b996 Build version 2023-03-06 08:42:48 +01:00
18fe6ecb86 Set version for rc 2023-03-06 08:42:48 +01:00
f02268c1a1 Merge pull request '#238' (#242) from #238 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#242
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #238
2023-03-06 08:42:21 +01:00
1b328dc20e Fixed translation #238 2023-03-06 08:05:30 +01:00
34c362a391 Improved game server handling for ontime #238 2023-03-06 08:05:08 +01:00
15dfc3f47c Added GameServer & ApiKey logic #238 2023-03-06 08:05:08 +01:00
91b2cf7546 Added GameServer handling & commands #238 2023-03-06 08:05:08 +01:00
a8dad6b223 Added GameServer data model #238 2023-03-06 08:05:08 +01:00
124209c371 Merge pull request '#240' (#241) from #240 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#241
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #240
2023-03-05 21:55:39 +01:00
d24c8e40de Merge branch '1.0.0' into #240 2023-03-05 21:47:53 +01:00
54004d10a5 Merge pull request 'Übersetzungen in Front und Backend aufräumen #232' (#237) from #232 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#237
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #232
2023-03-05 21:47:38 +01:00
a510cf731f Fixed german translation #232 2023-03-05 21:42:51 +01:00
23b7e4f59c Fixed english translation #232 2023-03-05 21:33:30 +01:00
24f90657e1 Fixed german translation #232 2023-03-05 21:22:22 +01:00
454fabb3e3 Added migration only mode #240 2023-03-04 18:57:51 +01:00
a588f8bf72 Merge pull request 'Verwarnungssystem #35' (#235) from #35 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#235
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #35
2023-02-24 08:49:08 +01:00
d75503569e Refactored translations #232 2023-02-23 10:58:08 +01:00
5b265488df Refactored translations #232 2023-02-23 10:56:07 +01:00
2d995544c3 Code refactoring #35 2023-02-23 08:58:04 +01:00
e5fb9fd504 Merge branch '1.0.0' into #35 2023-02-23 08:46:52 +01:00
a80bbc33cf Merge pull request 'Fixed table loading #220' (#236) from #220 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#236
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #220
2023-02-23 08:46:04 +01:00
6915515932 Fixed table loading #220 2023-02-22 21:02:49 +01:00
42b71525bd Merge pull request '#133' (#224) from #133 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#224
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Reviewed-by: Jonas <joni.drescher@web.de>
2023-02-22 19:29:16 +01:00
2674af64e9 Added warning commands #35 2023-02-22 08:44:08 +01:00
1eb625fe7a Improved warning handling #35 2023-02-22 08:39:50 +01:00
19f47a01e5 Added warnings service #35 2023-02-22 08:39:50 +01:00
8ff21debf0 Added user warning repository #35 2023-02-22 08:39:50 +01:00
89bcb655d2 Added user warning model #35 2023-02-22 08:39:50 +01:00
b9d33c5fd0 Merge branch '1.0.0' into #133 2023-02-21 22:45:30 +01:00
9ea1b14852 Optimized code #133 2023-02-21 22:44:42 +01:00
2763f254af Merge pull request 'Fixed db null handling #219' (#229) from #219 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#229
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #219
2023-02-21 21:10:18 +01:00
f7dc8d135a Improved SQL statements #219 2023-02-21 21:08:51 +01:00
d42b76ba87 Improved SQL statements #219 2023-02-21 20:51:28 +01:00
0f26db3d74 Merge pull request 'Der Bot muss wohl zwei mal gestartet werden, damit er die DB richtig läd #214' (#231) from #214 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#231
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #214
2023-02-21 20:43:05 +01:00
d9d3f8c8b0 Merge pull request 'Fixed add xp to author of reacted message #218' (#230) from #218 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#230
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #218
2023-02-21 20:42:52 +01:00
23ee963d65 Fixed formattings #133 2023-02-21 17:29:08 +01:00
f3024d2ea5 Fixed changes of rebase #133 2023-02-21 17:24:18 +01:00
Jonas Drescher
e463b19a73 added level table 2023-02-21 17:11:56 +01:00
15214b1c99 Fixed user filter #133 2023-02-21 17:10:34 +01:00
Jonas Drescher
dfcd958965 WIP: levels table 2023-02-21 17:10:32 +01:00
9274be6bb7 Merge branch '1.0.0' into #218 2023-02-21 13:21:33 +01:00
ac1affa937 Fixed seeder and module order #214 2023-02-21 13:19:34 +01:00
4e722d9c47 Fixed add xp to author of reacted message #218 2023-02-21 12:47:20 +01:00
6585576266 Merge branch '1.0.0' into #219 2023-02-21 12:43:15 +01:00
8937243725 Fixed db null handling #219 2023-02-21 12:42:47 +01:00
c841f39a03 Merge pull request 'Added confirm dialog on first discord login #210' (#228) from #210 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#228
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #210
2023-02-21 12:12:30 +01:00
a3fa7cb7b9 Merge pull request 'Improved server loading by route #216' (#227) from #216 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#227
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #216
2023-02-21 12:12:20 +01:00
f38b517b98 Added confirm dialog on first discord login #210 2023-02-21 12:09:29 +01:00
7d450a12ac Improved server loading by route #216 2023-02-21 11:50:30 +01:00
0ea1edff4d Merge pull request 'Removed api url from env #217' (#226) from #217 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#226
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #217
2023-02-21 11:34:09 +01:00
70775111c5 Removed api url from env #217 2023-02-21 11:33:49 +01:00
f42f2086e7 Merge pull request 'Fixed notification on OnMemberJoin #191' (#225) from #191 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#225
2023-02-21 10:17:47 +01:00
1f3b12501b Fixed notification on OnMemberJoin #191 2023-02-21 10:16:16 +01:00
c0882a8ad3 Merge pull request 'AutoRole #134' (#222) from #134 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#222
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #134
2023-02-21 09:54:35 +01:00
75ab159539 Added typing #134 2023-02-20 22:46:18 +01:00
ec9bc80392 Finished auto role rules #134 2023-02-20 22:30:25 +01:00
02d04725bd Added auto role rule list logic #134 2023-02-20 21:32:46 +01:00
10d79f8c2c Prepared auto role rules #134 2023-02-20 21:32:46 +01:00
a2dcbbc465 Finished auto role list #134 2023-02-20 21:32:46 +01:00
81fe7433bd Improved settings #134 2023-02-20 21:32:46 +01:00
ed5564dc7c [WIP] Improved auto roles #134 2023-02-20 21:32:46 +01:00
e0ca057399 [WIP] Added auto roles list #134 2023-02-20 21:32:46 +01:00
8f95e196ec Merge pull request 'Removed statistic module #190' (#213) from #190 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#213
Reviewed-by: Sven Heidemann <sven.heidemann@sh-edraft.de>
Closes #190
2023-02-20 14:17:51 +01:00
16b2deec6b Added requested changes #190 2023-02-19 21:33:08 +01:00
85e664e642 Removed statistic module #190 2023-02-19 19:46:13 +01:00
64985f5983 Merge pull request 'Client in Webinterface anzeigen #80' (#211) from #80_show_info_of_client into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#211
Reviewed-by: Sven Heidemann <sven.heidemann@sh-edraft.de>
Closes #80
2023-02-19 18:02:45 +01:00
Jonas Drescher
02ed6eb75b deleted unused comments #80 2023-02-19 18:01:13 +01:00
Jonas Drescher
b615f2608f added translation #80 2023-02-19 17:59:59 +01:00
Jonas Drescher
bf776177d4 added clients to server-dashboard #80 2023-02-19 17:45:50 +01:00
Jonas Drescher
a2a0056873 min = 0 fix on xp inputfield 2023-02-19 14:49:53 +01:00
Jonas Drescher
eb18fdea46 added Jonas to settings 2023-02-19 14:36:07 +01:00
Jonas Drescher
6945cd2eac added Jonas to settings 2023-02-19 14:31:00 +01:00
ef040f2b91 Fixed permission check 2023-02-19 14:25:41 +01:00
ba4ef693da Merge pull request '#130' (#209) from #130 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#209
2023-02-19 12:00:14 +01:00
07f2c4921c Merge branch '1.0.0' into #130 2023-02-19 12:00:09 +01:00
96339ed168 Fixed some stuff for deployment #130 2023-02-19 11:59:02 +01:00
9667f40730 Merge pull request 'Set version for stage build #130' (#208) from #130 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#208
2023-02-19 11:10:59 +01:00
5a9ad77761 Updated config #130 2023-02-19 11:09:34 +01:00
e4d1e229eb Set version for stage build #130 2023-02-19 10:59:40 +01:00
299fc65d1f Merge pull request 'Set version to build for staging' (#207) from #130 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#207
2023-02-19 10:39:45 +01:00
aa38623633 Set version to build for staging 2023-02-19 10:37:56 +01:00
fd9d938b8a Set version to build for staging 2023-02-19 10:29:29 +01:00
efbe6efc20 Merge pull request 'Mitglieder auf einem Server anzeigen #130' (#206) from #130 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#206
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #130
2023-02-18 14:56:38 +01:00
da3680a83e Improved imports #130 2023-02-18 14:45:51 +01:00
610ce42fa2 Fixed styling & added game server to profile #130 2023-02-18 13:37:03 +01:00
6149825101 Fixed sorting with null values #130 2023-02-18 13:05:45 +01:00
7193e58ba1 Fixed dashboard server filter #130 2023-02-18 12:54:56 +01:00
38417bd712 Fixed auth user confirmed check #130 2023-02-18 12:49:14 +01:00
43b6df2ba3 Improved spinner logic and table design #130 2023-02-18 12:42:51 +01:00
7d67b08ce6 Added leftServer handling to members list #130 2023-02-18 12:14:04 +01:00
afff27b273 Improved db updates #130 2023-02-18 11:44:13 +01:00
de8262dae1 Improved sidebar handling & added minecraftId to profile #130 2023-02-18 11:34:33 +01:00
b96288f4a3 Added member profile #130 2023-02-18 10:44:19 +01:00
1ca6debc59 Fixed server view in sidebar #130 2023-02-18 10:22:31 +01:00
dfe4f28e24 Improved sorting #130 2023-02-18 10:22:31 +01:00
fea259fa3b Renamed type_id to id for sorting #130 2023-02-18 10:22:31 +01:00
85452c9a74 Added members view #130 2023-02-18 10:22:30 +01:00
f44f77d7e5 Improved sidebar #130 2023-02-18 10:20:15 +01:00
b15bcec20a Updated config #130 2023-02-18 10:19:47 +01:00
ee351ee749 Improved routing #130 2023-02-18 10:19:47 +01:00
f847841582 Added routing by permissions #130 2023-02-18 10:19:45 +01:00
e2ef4f3bde Merge pull request 'Login in WI möglich trotz nicht bestätigter mail #77' (#205) from #77 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#205
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #77
2023-02-16 22:18:20 +01:00
3456c5f021 Merge pull request 'Bonus XP wenn man an einem Event teilnimmt #167' (#202) from #167 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#202
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #167
2023-02-16 22:18:10 +01:00
065e8b0645 Merge branch '1.0.0' into #77 2023-02-16 22:02:59 +01:00
f04a6066a1 Merge branch '1.0.0' into #167 2023-02-16 22:01:38 +01:00
c0d1288aef Merge pull request 'Erstellt am & Zuletzt bearbeitet am in Benutzertabellen #78' (#204) from #78 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#204
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #78
2023-02-16 22:01:24 +01:00
c4507d3aa1 Merge branch '1.0.0' into #167 2023-02-16 21:45:10 +01:00
1039a58d4f Merge branch '1.0.0' into #77 2023-02-16 21:44:53 +01:00
ed4d41d424 Merge branch '1.0.0' into #78 2023-02-16 21:44:32 +01:00
645e84a8fa Merge pull request 'Externe ontime Quelle: Minecraft #181' (#200) from #181 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#200
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #181
2023-02-16 21:44:20 +01:00
b9087dccb3 Fixed copy&paste error #181 2023-02-16 21:43:47 +01:00
4bb486f1d5 Merge branch '1.0.0' into #181 2023-02-16 21:08:48 +01:00
8efd0fc993 Added logic to prevent login when email not confirmed #77 2023-02-16 17:12:41 +01:00
6c0b48a941 Added logic to show createdAt & modifiedAt in auth user list #78 2023-02-16 17:00:55 +01:00
77946cb3a8 Added logic to add bonus xp when joining the event channel #167 2023-02-13 23:15:04 +01:00
5953c82a9b Fixed formatting #167 2023-02-13 23:14:57 +01:00
6bf73fcf91 Added logic to save active events locally #167 2023-02-13 23:14:49 +01:00
3844240930 Fixed filter error #181 2023-02-13 22:21:18 +01:00
efa18944fe Edited my API config 2023-02-13 20:47:32 +01:00
f435d779a7 Merge branch '1.0.0' into #181 2023-02-12 21:44:42 +01:00
cd34d18205 Merge pull request 'Als Mitglied möchte ich anhand meiner Rechte Daten ändern können oder daran gehindert werden #198' (#199) from #198 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#199
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #198
2023-02-12 21:44:27 +01:00
9e2a0441d3 Merge branch '1.0.0' into #198 2023-02-12 20:36:05 +01:00
898e27550e Merge pull request 'Added logic to check if user is allowed to see requested data #89' (#197) from #89 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#197
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #89
2023-02-12 20:35:54 +01:00
60990db88d Fixed collection building #89 2023-02-12 20:33:28 +01:00
ce1cdd4017 Added user joined game server validation checks on start #181 2023-02-12 20:30:42 +01:00
9a8f8a13f6 Improved user joined game server mutation #181 2023-02-12 20:00:47 +01:00
667bb708d9 Improved user joined game server mutation #181 2023-02-12 19:47:27 +01:00
54cb6cf8a0 Fixed user filter #181 2023-02-12 17:42:59 +01:00
aa16847fbf Added minecraft register commands #181 2023-02-12 17:22:58 +01:00
2ef4d079ed Added minecraft id #181 2023-02-12 16:55:35 +01:00
bd4e088032 Added mutations for user joined game server #181 2023-02-12 16:39:26 +01:00
1e74584e71 Added user joined game server gql query #181 2023-02-12 16:16:17 +01:00
0b5acdea58 Added user joined game server model #181 2023-02-12 15:42:02 +01:00
91bbb2f2e9 Added permission check on data mutation #198 2023-02-12 14:59:20 +01:00
dd64435c65 Added logic to check if user is allowed to see requested data #89 2023-02-11 13:11:55 +01:00
84937dde0a Merge pull request 'Ausgewählter Server besser darstellen #131' (#196) from #131 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#196
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #131
2023-02-11 10:42:03 +01:00
ca5744ea39 Removed theme.css #131 2023-02-11 10:41:44 +01:00
f68bd875b5 Merge branch '1.0.0' into #131 2023-02-11 10:40:10 +01:00
429f8b2819 Merge pull request 'graphql part3/3 #162-3' (#194) from #162-3 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#194
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
Closes #162
2023-02-11 10:39:49 +01:00
7fb8b521e4 Merge branch '1.0.0' into #162-3 2023-02-11 10:38:51 +01:00
936b8e9cb6 Merge pull request 'graphql part2/3 #162-2' (#193) from #162-2 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#193
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
2023-02-11 10:38:28 +01:00
1fa6f44f76 Merge branch '1.0.0' into #162-2 2023-02-11 10:38:20 +01:00
f04d40ce75 Readded browserlist #162-2 2023-02-11 10:37:09 +01:00
45a6b49cf5 Improved way to load and show server in sidebar #131 2023-02-11 10:34:46 +01:00
4822348e01 Improved way to load server for server dashboard #131 2023-02-11 10:34:35 +01:00
1d1fc8a876 Merge pull request 'GraphQL Part1 (gql endpoint only) #162' (#192) from #162 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#192
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
2023-02-11 10:30:41 +01:00
a6df06f13a Added logic to create default api-key for frontend #162-3 2023-02-09 22:09:02 +01:00
7f14aff1bd Added api-key commands #162-3 2023-02-09 20:22:46 +01:00
d03ea1d970 Added ApiKeys to db #162-3 2023-02-09 19:29:25 +01:00
f144564806 Secured graphql playground #162-2 2023-02-09 18:29:19 +01:00
f7c27b77ee Added graphql support #162-2 2023-02-09 16:36:50 +01:00
6aca981fd1 [WIP] Switched from rest to GraphQL #162-2 2023-02-09 16:09:34 +01:00
4266db7e35 [WIP] Updated packages #162-2 2023-02-09 15:27:39 +01:00
667b9fa87e [WIP] Switched to gql #162-2 2023-02-09 15:19:31 +01:00
79837afdfb Removed server route #162-2 2023-02-09 14:32:38 +01:00
8273b2b98e Build frontend & fixed oauth scopes #162 2023-02-09 14:30:51 +01:00
eaa22efd08 Merge branch '1.0.0' into #162 2023-02-08 19:26:21 +01:00
b33c5dc9bf Fixed mutations #162 2023-02-08 19:24:07 +01:00
e9559dec08 Fixed queries #162 2023-02-08 19:10:56 +01:00
5d470be583 Changed from snake to camel case #162 2023-02-08 19:05:32 +01:00
1dfe7edcba Added services to di #162 2023-02-08 17:50:43 +01:00
af8c2dea60 Added mutations #162 2023-02-08 17:48:54 +01:00
23e238b7d5 Removed server from queries where user set #162 2023-02-08 12:34:47 +01:00
fde318b85d Improved filters & queries #162 2023-02-08 12:32:16 +01:00
93c60b9176 Improved filters #162 2023-02-08 12:05:02 +01:00
12f8f669ed Improved filters #162 2023-02-07 19:09:27 +01:00
36fd3c73b9 Added client filter #162 2023-02-07 18:58:09 +01:00
3f7cfc47af Finished auto role filter #162 2023-02-07 18:53:28 +01:00
eb58c34c4d Added auto role filter #162 2023-02-07 17:52:38 +01:00
e3c0a0dea3 Reformatted files with black #162 2023-02-07 17:07:25 +01:00
dbfae8d8a4 Added more gql filters #162 2023-02-07 17:07:14 +01:00
16066864ed Improved queries & filtering #162 2023-01-16 19:18:23 +01:00
807827e30f Improved queries & filtering #162 2023-01-16 15:13:45 +01:00
c75cc54d16 Improved queries #162 2023-01-15 17:47:40 +01:00
6a1ad1ec9f Added filters #162 2023-01-15 17:06:04 +01:00
8256ebed71 Added auto role query #162 2023-01-15 16:24:16 +01:00
eb7fce140a Added more queries #162 2023-01-15 11:00:00 +01:00
ebcf876457 Added more queries #162 2023-01-15 10:59:54 +01:00
5efb1da0b8 Added more queries #162 2023-01-15 10:59:25 +01:00
b9e66bba9d Added more queries #162 2023-01-15 10:36:09 +01:00
b8484185e9 Improved level stuff #162 2023-01-15 09:51:40 +01:00
552e686aeb Updated model #162 2023-01-15 02:37:35 +01:00
efb772094b Updated cpl-core #162 2023-01-15 02:35:39 +01:00
95b9eea236 Added graphql from prototype #162 2023-01-15 02:28:28 +01:00
b95a951a1b Merge branch 'prototype/graphql/ariadne' into #162
# Conflicts:
#	kdb-bot/cpl-workspace.json
#	kdb-bot/src/bot/config
#	kdb-bot/src/bot/module_list.py
#	kdb-bot/src/bot_api/api.py
#	kdb-bot/src/bot_data/service/client_repository_service.py
#	kdb-bot/src/bot_data/service/server_repository_service.py
2023-01-15 02:25:05 +01:00
df42acec26 Added mutations without saving data 2023-01-07 16:31:28 +01:00
44204f5b94 Improved query & filtering 2023-01-07 15:53:53 +01:00
ce85bb332a Improved query & filtering 2023-01-07 15:53:44 +01:00
7a836a7f59 Added filtering 2023-01-07 15:17:11 +01:00
dacb429d9b Moved graphql stuff to own lib 2023-01-07 12:41:22 +01:00
77e18027a0 Improved ariadne with DI 2023-01-06 23:18:40 +01:00
b13695b018 Moved to ariadne 2023-01-06 16:21:21 +01:00
75500076a7 Improved gql data layer 2023-01-06 14:47:45 +01:00
5455a6b359 Added first graphene models 2023-01-06 14:14:37 +01:00
419 changed files with 18588 additions and 17520 deletions

View File

@ -0,0 +1,34 @@
from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC
class query(GenerateSchematicABC):
def __init__(self, *args: str):
GenerateSchematicABC.__init__(self, *args)
def get_code(self) -> str:
import textwrap
code = textwrap.dedent(
"""\
from bot_graphql.abc.data_query_abc import DataQueryABC
class $ClassName(DataQueryABC):
def __init__(self):
DataQueryABC.__init__(self, "Name")
self.set_field("id", self.resolve_id)
@staticmethod
def resolve_id(x, *_):
return x.id
"""
)
return self.build_code_str(
code,
ClassName=self._class_name,
)
@classmethod
def register(cls):
GenerateSchematicABC.register(cls, "query", [])

View File

@ -6,13 +6,13 @@
"bot-api": "src/bot_api/bot-api.json",
"bot-core": "src/bot_core/bot-core.json",
"bot-data": "src/bot_data/bot-data.json",
"bot-graphql": "src/bot_graphql/bot-graphql.json",
"auto-role": "src/modules/auto_role/auto-role.json",
"base": "src/modules/base/base.json",
"boot-log": "src/modules/boot_log/boot-log.json",
"database": "src/modules/database/database.json",
"level": "src/modules/level/level.json",
"permission": "src/modules/permission/permission.json",
"stats": "src/modules/stats/stats.json",
"technician": "src/modules/technician/technician.json",
"checks": "tools/checks/checks.json",
"get-version": "tools/get_version/get-version.json",

@ -1 +1 @@
Subproject commit 6b25cc87fced30b5846505d95f20285a3e4d7adf
Subproject commit 62475d65465f289604c7a32d23b5c29bb8cd38a4

View File

@ -14,6 +14,8 @@ RUN apk add nano
RUN pip install -r requirements.txt --extra-index-url https://pip.sh-edraft.de
RUN pip install flask[async]
RUN pip install dnspython==2.2.1 # https://stackoverflow.com/questions/75137717/eventlet-dns-python-attribute-error-module-dns-rdtypes-has-no-attribute-any
# RUN pip install dnspython==2.2.1 # https://stackoverflow.com/questions/75137717/eventlet-dns-python-attribute-error-module-dns-rdtypes-has-no-attribute-any
# ^ probably fixed py package updates
CMD [ "bash", "/app/bot/bot"]

View File

@ -15,7 +15,7 @@ __title__ = "bot"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -2,9 +2,9 @@
"ProjectSettings": {
"Name": "bot",
"Version": {
"Major": "0",
"Minor": "3",
"Micro": "1.post1"
"Major": "1",
"Minor": "0",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
@ -18,20 +18,22 @@
"Dependencies": [
"cpl-core==2022.12.1.post3",
"cpl-translation==2022.12.1",
"cpl-query==2022.12.2.post1",
"cpl-discord==2022.12.1.post2",
"cpl-query==2022.12.2.post2",
"cpl-discord==2022.12.2.post1",
"Flask==2.2.2",
"Flask-Classful==0.14.2",
"Flask-Cors==3.0.10",
"PyJWT==2.6.0",
"waitress==2.1.2",
"Flask-SocketIO==5.3.2",
"eventlet==0.33.2",
"eventlet==0.33.3",
"requests-oauthlib==1.3.1",
"icmplib==3.0.3"
"icmplib==3.0.3",
"ariadne==0.17.1"
],
"DevDependencies": [
"cpl-cli==2022.12.1.post3"
"cpl-cli==2022.12.1.post3",
"pygount==1.5.1"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},
@ -55,13 +57,13 @@
"../bot_api/bot-api.json",
"../bot_core/bot-core.json",
"../bot_data/bot-data.json",
"../bot_graphql/bot-graphql.json",
"../modules/auto_role/auto-role.json",
"../modules/base/base.json",
"../modules/boot_log/boot-log.json",
"../modules/database/database.json",
"../modules/level/level.json",
"../modules/permission/permission.json",
"../modules/stats/stats.json",
"../modules/technician/technician.json"
]
}

@ -1 +1 @@
Subproject commit b0ae87621bbe54fd9c5650071ec8c1c9ec32df48
Subproject commit 0c9463753731ab1f5d0f916d21ac7ea304742995

View File

@ -15,7 +15,7 @@ __title__ = "bot.extension"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -4,13 +4,13 @@ from bot_api.api_module import ApiModule
from bot_core.core_extension.core_extension_module import CoreExtensionModule
from bot_core.core_module import CoreModule
from bot_data.data_module import DataModule
from bot_graphql.graphql_module import GraphQLModule
from modules.auto_role.auto_role_module import AutoRoleModule
from modules.base.base_module import BaseModule
from modules.boot_log.boot_log_module import BootLogModule
from modules.database.database_module import DatabaseModule
from modules.level.level_module import LevelModule
from modules.permission.permission_module import PermissionModule
from modules.stats.stats_module import StatsModule
from modules.technician.technician_module import TechnicianModule
@ -23,13 +23,13 @@ class ModuleList:
[
CoreModule, # has to be first!
DataModule,
GraphQLModule,
PermissionModule,
LevelModule,
DatabaseModule,
AutoRoleModule,
BaseModule,
LevelModule,
ApiModule,
StatsModule,
TechnicianModule,
# has to be last!
BootLogModule,

View File

@ -4,15 +4,20 @@ from cpl_core.dependency_injection import ServiceCollectionABC
from cpl_core.environment import ApplicationEnvironmentABC
from bot_data.abc.migration_abc import MigrationABC
from bot_data.migration.api_key_migration import ApiKeyMigration
from bot_data.migration.api_migration import ApiMigration
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
from bot_data.migration.auto_role_migration import AutoRoleMigration
from bot_data.migration.db_history_migration import DBHistoryMigration
from bot_data.migration.initial_migration import InitialMigration
from bot_data.migration.level_migration import LevelMigration
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
from bot_data.migration.stats_migration import StatsMigration
from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration
from bot_data.migration.user_message_count_per_hour_migration import (
UserMessageCountPerHourMigration,
)
from bot_data.migration.user_warning_migration import UserWarningMigration
from bot_data.service.migration_service import MigrationService
@ -32,3 +37,8 @@ class StartupMigrationExtension(StartupExtensionABC):
services.add_transient(MigrationABC, StatsMigration) # 09.11.2022 #46 - 0.3.0
services.add_transient(MigrationABC, AutoRoleFix1Migration) # 30.12.2022 #151 - 0.3.0
services.add_transient(MigrationABC, UserMessageCountPerHourMigration) # 11.01.2023 #168 - 0.3.1
services.add_transient(MigrationABC, ApiKeyMigration) # 09.02.2023 #162 - 1.0.0
services.add_transient(MigrationABC, UserJoinedGameServerMigration) # 12.02.2023 #181 - 1.0.0
services.add_transient(MigrationABC, RemoveStatsMigration) # 19.02.2023 #190 - 1.0.0
services.add_transient(MigrationABC, UserWarningMigration) # 21.02.2023 #35 - 1.0.0
services.add_transient(MigrationABC, DBHistoryMigration) # 06.03.2023 #246 - 1.0.0

View File

@ -1,51 +1,27 @@
{
"api": {
"api": {
"test_mail": {
"message": "Dies ist eine Test-Mail vom Krümelmonster Web Interface\nGesendet von {}-{}",
"subject": "Krümelmonster Web Interface Test-Mail"
}
},
"auth": {
"confirmation": {
"message": "Öffne den Link, um die E-Mail zu bestätigen:\n{}auth/register/{}",
"subject": "E-Mail für {} {} bestätigen"
},
"forgot_password": {
"message": "Öffne den Link, um das Passwort zu ändern:\n{}auth/forgot-password/{}",
"subject": "Passwort für {} {} zurücksetzen"
}
},
"mail": {
"automatic_mail": "\n\nDies ist eine automatische E-Mail.\nGesendet von {}-{}@{}"
}
},
"common": {
"hello_world": "Hallo Welt",
"bot_has_no_permission_message": "Ey!!!\nWas soll das?\nIch habe keine Berechtigungen :(\nScheiß System...",
"no_permission_message": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯",
"not_implemented_yet": "Ey Alter, das kann ich noch nicht...",
"presence": {
"booting": "{} Ich fahre gerade hoch...",
"running": "{} Ich esse Kekse :D",
"restart": "{} Muss neue Kekse holen...",
"shutdown": "{} Ich werde bestimmt wieder kommen..."
},
"errors": {
"error": "Es gab einen Fehler. Meld dich bitte bei einem Admin.",
"command_error": "Es gab einen Fehler beim bearbeiten des Befehls. Meld dich bitte bei einem Admin.",
"missing_required_argument": "Fehler: Ein benötigter Parameter fehlt!",
"argument_parsing_error": "Fehler: Parameter konnte nicht gelesen werden!",
"unexpected_quote_error": "Fehler: Unerwarteter Zitat Fehler!",
"invalid_end_of_quoted_string_error": "Fehler: Ungültiges Zitatende!",
"expected_closing_quote_error": "Fehler: Erwarte Zitatende!",
"bad_argument": "Fehler: Ungültiger Parameter!",
"bad_union_argument": "Fehler: Ungültiger Union Parameter!",
"private_message_only": "Fehler: Nur private Nachrichten sind erlaubt!",
"no_private_message": "Fehler: Private Nachrichten sind nicht erlaubt!",
"check_failure": "Fehler: Du hast nicht die benötigte Berechtigung!",
"check_any_failure": "Fehler: Alle checks sind Fehlgeschlagen!",
"command_not_found": "Fehler: Befehl konnte nicht gefunden werden!",
"disabled_command": "Fehler: Befehl wurde deaktiviert!",
"command_invoke_error": "Fehler: Befehl konnte nicht aufgerufen werden!",
"too_many_arguments": "Fehler: Zu viele Parameter!",
"user_input_error": "Fehler: Eingabefehler!",
"command_on_cooldown": "Fehler: Befehl befindet sich im cooldown!",
"max_concurrency_reached": "Fehler: Maximale Parallelität erreicht!",
"not_owner": "Fehler: Du bist nicht mein besitzer!",
"missing_permissions": "Fehler: Berechtigungen fehlen!",
"bot_missing_permissions": "Fehler: Mir fehlen Berechtigungen!",
"missing_role": "Fehler: Benötigte Rolle fehlt!",
"bot_missing_role": "Fehler: Mir fehlt eine benötigte Rolle!",
"missing_any_role": "Fehler: Alle benötigten Rollen fehlen!",
"bot_missing_any_role": "Fehler: Mir fehlen alle benötigten Rollen!",
"nsfw_channel_required": "Fehler: NSFW Kanal benötigt!",
"extension_error": "Fehler: Erweiterungsfehler!",
"extension_already_loaded": "Fehler: Erweiterung wurde bereits geladen!",
"extension_not_loaded": "Fehler: Erweiterung wurde nicht geladen!",
"no_entry_point_error": "Fehler: Kein Eintrittspunkt!",
"extension_failed": "Fehler: Erweiterung ist fehlgeschlagen!",
"bot_not_ready_yet": "Ey Alter! Gedulde dich doch mal! ..."
},
"colors": {
"blue": "Blau",
"dark_blue": "Dunkelblau",
@ -69,242 +45,296 @@
"red": "Rot",
"teal": "Blaugrün",
"yellow": "Gelb"
},
"errors": {
"argument_parsing_error": "Fehler: Parameter konnte nicht gelesen werden!",
"bad_argument": "Fehler: Ungültiger Parameter!",
"bad_union_argument": "Fehler: Ungültiger Union Parameter!",
"bot_missing_any_role": "Fehler: Mir fehlen alle benötigten Rollen!",
"bot_missing_permissions": "Fehler: Mir fehlen Berechtigungen!",
"bot_missing_role": "Fehler: Mir fehlt eine benötigte Rolle!",
"bot_not_ready_yet": "Ey Alter! Gedulde dich doch mal! ...",
"check_any_failure": "Fehler: Alle Checks sind Fehlgeschlagen!",
"check_failure": "Fehler: Du hast nicht die benötigte Berechtigung!",
"command_error": "Es gab einen Fehler beim Bearbeiten des Befehls. Melde dich bitte bei einem Admin.",
"command_invoke_error": "Fehler: Befehl konnte nicht aufgerufen werden!",
"command_not_found": "Fehler: Befehl konnte nicht gefunden werden!",
"command_on_cooldown": "Fehler: Befehl befindet sich im Cooldown!",
"disabled_command": "Fehler: Befehl wurde deaktiviert!",
"error": "Es gab einen Fehler. Melde dich bitte bei einem Admin.",
"expected_closing_quote_error": "Fehler: Erwarte Zitatende!",
"extension_already_loaded": "Fehler: Erweiterung wurde bereits geladen!",
"extension_error": "Fehler: Erweiterungsfehler!",
"extension_failed": "Fehler: Erweiterung ist fehlgeschlagen!",
"extension_not_loaded": "Fehler: Erweiterung wurde nicht geladen!",
"invalid_end_of_quoted_string_error": "Fehler: Ungültiges Zitatende!",
"max_concurrency_reached": "Fehler: Maximale Parallelität erreicht!",
"missing_any_role": "Fehler: Alle benötigten Rollen fehlen!",
"missing_permissions": "Fehler: Berechtigungen fehlen!",
"missing_required_argument": "Fehler: Ein benötigter Parameter fehlt!",
"missing_role": "Fehler: Benötigte Rolle fehlt!",
"no_entry_point_error": "Fehler: Kein Eintrittspunkt!",
"no_private_message": "Fehler: Private Nachrichten sind nicht erlaubt!",
"not_owner": "Fehler: Du bist nicht mein besitzer!",
"nsfw_channel_required": "Fehler: NSFW Kanal benötigt!",
"private_message_only": "Fehler: Nur private Nachrichten sind erlaubt!",
"too_many_arguments": "Fehler: Zu viele Parameter!",
"unexpected_quote_error": "Fehler: Unerwarteter Fehler beim Anführungszeichen!",
"user_input_error": "Fehler: Eingabefehler!"
},
"hello_world": "Hallo Welt",
"no_permission_message": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯",
"not_implemented_yet": "Ey Alter, das kann ich noch nicht...",
"presence": {
"booting": "Ich fahre gerade hoch...",
"restart": "Muss neue Kekse holen...",
"running": "Ich esse Kekse :D",
"shutdown": "Ich werde bestimmt wieder kommen..."
}
},
"modules": {
"auto_role": {
"list": {
"title": "Beobachtete Nachrichten:",
"description": "Von auto-role beobachtete Nachrichten:",
"auto_role_id": "auto-role Id",
"message_id": "Nachricht-Id"
},
"add": {
"success": "auto-role für die Nachricht {} wurde hinzugefügt :D",
"error": {
"not_found": "Nachricht {} in {} nicht gefunden!",
"already_exists": "auto-role für die Nachricht {} existiert bereits!"
}
"already_exists": "auto-role für die Nachricht {} existiert bereits!",
"not_found": "Nachricht {} in {} nicht gefunden!"
},
"remove": {
"success": "auto-role {} wurde entfernt :D",
"error": {
"not_found": "auto-role {} nicht gefunden!"
}
"success": "auto-role für die Nachricht {} wurde hinzugefügt :D"
},
"error": {
"nothing_found": "Keine auto-role Einträge gefunden."
},
"rule": {
"list": {
"title": "auto-role Regeln:",
"description": "Von auto-role angewendete Regeln:",
"auto_role_rule_id": "auto-role Regel Id",
"emoji": "Emoji",
"role": "Rolle"
},
"add": {
"success": "Regel {} -> {} für auto-role {} wurde hinzugefügt :D",
"error": {
"not_found": "Regel für auto-role {} nicht gefunden!",
"emoji_not_found": "Emoji {} für auto-role Regel {} nicht gefunden!",
"role_not_found": "Rolle {} für auto-role Regel {} nicht gefunden!",
"already_exists": "Regel für auto-role {} existiert bereits!"
}
"auto_role_id": "auto-role Id",
"description": "Von auto-role beobachtete Nachrichten:",
"message_id": "Nachricht-Id",
"title": "Beobachtete Nachrichten:"
},
"remove": {
"success": "Regel für auto-role {} wurde entfernt :D",
"error": {
"not_found": "Regel für auto-role {} nicht gefunden!"
}
"not_found": "auto-role {} nicht gefunden!"
},
"success": "auto-role {} wurde entfernt :D"
},
"rule": {
"add": {
"error": {
"already_exists": "Regel für auto-role {} existiert bereits!",
"emoji_not_found": "Emoji {} für auto-role Regel {} nicht gefunden!",
"not_found": "Regel für auto-role {} nicht gefunden!",
"role_not_found": "Rolle {} für auto-role Regel {} nicht gefunden!"
},
"success": "Regel {} -> {} für auto-role {} wurde hinzugefügt :D"
},
"error": {
"id_not_found": "Kein auto-role Eintrag mit der Id gefunden!"
}
}
},
"moderator": {
"purge_message": "Na gut..., ich lösche alle Nachrichten wenns sein muss."
"list": {
"auto_role_rule_id": "auto-role Regel Id",
"description": "Von auto-role angewendete Regeln:",
"emoji": "Emoji",
"role": "Rolle",
"title": "auto-role Regeln:"
},
"remove": {
"error": {
"not_found": "Regel für auto-role {} nicht gefunden!"
},
"success": "Regel für auto-role {} wurde entfernt :D"
}
}
},
"base": {
"technician_error_message": "Es gab ein Fehler mit dem Event: {}\nDatum und Zeit: {}\nSchau bitte ins log für Details.\nUUID: {}",
"technician_command_error_message": "Es gab ein Fehler mit dem Befehl: {} ausgelöst von {} -> {}\nDatum und Zeit: {}\nSchau bitte ins log für Details.\nUUID: {}",
"welcome_message": "Hello There!\nIch heiße dich bei {} herzlichst Willkommen!",
"welcome_message_for_team": "{} hat gerade das Irrenhaus betreten.",
"goodbye_message": "Schade, dass du uns so schnell verlässt :(",
"afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?",
"afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)",
"member_joined_help_voice_channel": "{} braucht hilfe, bitte kümmer dich drum :D",
"pong": "Pong",
"info": {
"title": "Krümmelmonster",
"description": "Informationen über mich",
"fields": {
"version": "Version",
"ontime": "Ontime",
"sent_message_count": "Gesendete Nachrichten",
"received_message_count": "Empfangene Nachrichten",
"deleted_message_count": "Gelöschte Nachrichten",
"received_command_count": "Empfangene Befehle",
"moved_users_count": "Verschobene Benutzer",
"modules": "Module"
},
"footer": ""
},
"mass_move": {
"moved": "Alle Personen aus {} wurden nach {} verschoben.",
"channel_from_error": "Du musst dich in einem Voicechannel befinden oder die Option \"channel_from\" mit angeben."
},
"presence": {
"changed": "Presence wurde geändert.",
"removed": "Presence wurde entfernt.",
"max_char_count_exceeded": "Der Text darf nicht mehr als 128 Zeichen lang sein!"
},
"user": {
"atr": {
"id": "Id",
"name": "Name",
"discord_join": "Discord beigetreten am",
"last_join": "Server beigetreten am",
"xp": "XP",
"ontime": "Ontime",
"roles": "Rollen",
"joins": "Beitritte",
"lefts": "Abgänge",
"warnings": "Verwarnungen"
},
"info": {
"footer": ""
},
"get": {
"xp": "{} hat {} xp",
"ontime": "{} war insgesamt {} Stunden aktiv in einem Sprachkanal"
},
"set": {
"xp": "{} hat nun {} xp",
"game_server": {
"error": {
"value_type_not_numeric": "Der angegebende Wert ist keine Ganzzahl! :(",
"type_error": "Der angegebene Wert ist keine Zahl! :("
}
"nothing_found": "Keine Gameserver gefunden."
},
"list": {
"title": "Gameserver",
"description": "Konfigurierte Gameserver:",
"name": "Name",
"api_key": "API Key"
},
"add": {
"success": "Gameserver {} wurde hinzugefügt :)"
},
"remove": {
"success": "Gameserver wurde entfernt :D"
}
},
"goodbye_message": "Schade, dass du uns so schnell verlässt :(",
"info": {
"description": "Informationen über mich",
"fields": {
"deleted_message_count": "Gelöschte Nachrichten",
"modules": "Module",
"moved_users_count": "Verschobene Benutzer",
"ontime": "Ontime",
"received_command_count": "Empfangene Befehle",
"received_message_count": "Empfangene Nachrichten",
"sent_message_count": "Gesendete Nachrichten",
"version": "Version"
},
"footer": "",
"title": "Krümelmonster"
},
"mass_move": {
"channel_from_error": "Du musst dich in einem Voicechannel befinden oder die Option \"channel_from\" mit angeben.",
"moved": "Alle Personen aus {} wurden nach {} verschoben."
},
"member_joined_help_voice_channel": "{} braucht Hilfe, bitte kümmere dich drum :D",
"pong": "Pong",
"presence": {
"changed": "Presence wurde geändert.",
"max_char_count_exceeded": "Der Text darf nicht mehr als 128 Zeichen lang sein!",
"removed": "Presence wurde entfernt."
},
"register": {
"not_found": "Benutzer konnte nicht gefunden werden!",
"success": "Spieler wurde mit dem Mitglied verlinkt :D"
},
"technician_command_error_message": "Es gab ein Fehler mit dem Befehl: {} ausgelöst von {} -> {}\nDatum und Zeit: {}\nSchau bitte ins Log für Details.\nUUID: {}",
"technician_error_message": "Es gab ein Fehler mit dem Event: {}\nDatum und Zeit: {}\nSchau bitte ins Log für Details.\nUUID: {}",
"unregister": {
"success": "Verlinkung wurde entfernt :D"
},
"user": {
"add": {
"xp": "Die {} von {} wurden um {} erhöht"
},
"atr": {
"discord_join": "Discord beigetreten am",
"id": "Id",
"joins": "Beitritte",
"last_join": "Server beigetreten am",
"lefts": "Abgänge",
"name": "Name",
"ontime": "Ontime",
"roles": "Rollen",
"warnings": "Verwarnungen",
"xp": "XP"
},
"error": {
"atr_not_found": "Das Attribut {} konnte nicht gefunden werden :("
},
"get": {
"ontime": "{} war insgesamt {} Stunden aktiv in einem Sprachkanal",
"xp": "{} hat {} xp"
},
"info": {
"footer": ""
},
"remove": {
"xp": "Die {} von {} wurden um {} verringert"
},
"reset": {
"xp": "Die {} von {} wurden entfernt",
"ontime": "Die {} von {} wurden entfernt"
"ontime": "Die {} von {} wurden entfernt",
"xp": "Die {} von {} wurden entfernt"
},
"set": {
"error": {
"atr_not_found": "Das Attribut {} konnte nicht gefunden werden :("
}
"type_error": "Der angegebene Wert ist keine Zahl! :(",
"value_type_not_numeric": "Der angegebende Wert ist keine Ganzzahl! :("
},
"xp": "{} hat nun {} xp"
}
},
"warnings": {
"add": {
"failed": "Verwarnung konnte nicht hinzugefügt werden :(",
"success": "Verwarnung wurde hinzugefügt :)"
},
"first": "Bei der nächsten Verwarnung wirst du auf das vorherige Level zurückgesetzt!",
"kick": "Ich musste {} aufgrund zu vieler Verwarnungen kicken",
"remove": {
"failed": "Verwarnung konnte nicht entfernt werden :(",
"success": "Verwarnung wurde entfernt :)"
},
"removed": "Die Verwarnung '{}' wurde entfernt.",
"second": "Bei der nächsten verwarnung wirst du auf das erste Level zurückgesetzt!",
"show": {
"description": "Beschreibung",
"id": "Id"
},
"team_removed": "Die Verwarnung '{}' an {} wurde entfernt.",
"team_warned": "{} wurde verwarnt. Der Grund ist: {}",
"third": "Bei der nächsten verwarnung wirst du gekickt und zurückgesetzt!",
"warned": "Du wurdest verwarnt. Der Grund ist: {}"
},
"welcome_message": "Hello There!\nIch heiße dich bei {} herzlichst Willkommen!",
"welcome_message_for_team": "{} hat gerade das Irrenhaus betreten."
},
"boot_log": {
"login_message": "Ich bin on the line :D\nDer Scheiß hat {} Sekunden gedauert"
},
"level": {
"new_level_message": "{} ist nun Level {}",
"seeding_started": "Levelsystem wird neu geladen...",
"seeding_failed": "Levelsystem konnte nicht neu geladen werden :(",
"seeding_finished": "Levelsystem wurde Erfolgreich neu geladen :)",
"error": {
"nothing_found": "Keine Level Einträge gefunden.",
"level_with_name_already_exists": "Ein Level mit dem Namen {} existiert bereits!",
"level_with_xp_already_exists": "Das Level {} hat bereits die Mindest-XP {}!"
},
"list": {
"title": "Level:",
"description": "Konfigurierte Level:",
"name": "Name",
"min_xp": "Mindest-XP",
"permission_int": "Berechtigungen"
},
"create": {
"created": "Level {} mit Berechtigungen {} wurde erstellt :D"
},
"edit": {
"edited": "Level {} wurde bearbeitet :D",
"color_invalid": "Die Farbe {} ist ungültig!",
"permission_invalid": "Der Berechtigungswert {} ist ungültig!",
"not_found": "Level {} nicht gefunden!"
},
"remove": {
"success": "Level {} wurde entfernt :D",
"error": {
"not_found": "Level {} nicht gefunden!"
}
},
"down": {
"already_first": "{} hat bereits das erste Level.",
"success": "{} wurde auf Level {} runtergesetzt :)",
"failed": "{} konnte nicht runtergesetzt werden :("
"failed": "{} konnte nicht runtergesetzt werden :(",
"success": "{} wurde auf Level {} runtergesetzt :)"
},
"edit": {
"color_invalid": "Die Farbe {} ist ungültig!",
"edited": "Level {} wurde bearbeitet :D",
"not_found": "Level {} nicht gefunden!",
"permission_invalid": "Der Berechtigungswert {} ist ungültig!"
},
"error": {
"level_with_name_already_exists": "Ein Level mit dem Namen {} existiert bereits!",
"level_with_xp_already_exists": "Das Level {} hat bereits die Mindest-XP {}!",
"nothing_found": "Keine Einträge gefunden."
},
"list": {
"description": "Konfigurierte Level:",
"min_xp": "Mindest-XP",
"name": "Name",
"permission_int": "Berechtigungen",
"title": "Level:"
},
"new_level_message": "{} ist nun Level {}",
"remove": {
"error": {
"not_found": "Level {} nicht gefunden!"
},
"success": "Level {} wurde entfernt :D"
},
"seeding_failed": "Levelsystem konnte nicht neu geladen werden :(",
"seeding_finished": "Levelsystem wurde erfolgreich neu geladen :)",
"seeding_started": "Levelsystem wird neu geladen...",
"set": {
"already_level": "{} hat bereits das Level {} :/",
"failed": "Das Level von {} konnte nicht auf {} gesetzt werden :(",
"not_found": "Das Level {} konnte nicht gefunden werden :(",
"success": "{} ist nun Level {} :)"
},
"up": {
"already_last": "{} hat bereits das höchste Level.",
"success": "{} wurde auf Level {} hochgesetzt :)",
"failed": "{} konnte nicht hochgesetzt werden :("
},
"set": {
"already_level": "{} hat bereits das Level {} :/",
"success": "{} ist nun Level {} :)",
"failed": "Das Level von {} konnte nicht auf {} gesetzt werden :(",
"not_found": "Das Level {} konnte nicht gefunden werden :("
"failed": "{} konnte nicht hochgesetzt werden :(",
"success": "{} wurde auf Level {} hochgesetzt :)"
}
},
"database": {},
"permission": {},
"stats": {
"list": {
"statistic": "Statistik",
"description": "Beschreibung",
"nothing_found": "Keine Statistiken gefunden."
},
"view": {
"statistic": "Statistik",
"description": "Beschreibung",
"failed": "Statistik kann nicht gezeigt werden :("
},
"add": {
"failed": "Statistik kann nicht hinzugefügt werden :(",
"success": "Statistik wurde hinzugefügt :D"
},
"edit": {
"failed": "Statistik kann nicht bearbeitet werden :(",
"success": "Statistik wurde gespeichert :D"
},
"remove": {
"failed": "Statistik kann nicht gelöscht werden :(",
"success": "Statistik wurde gelöscht :D"
}
"moderator": {
"purge_message": "Na gut..., ich lösche alle Nachrichten wenns sein muss."
},
"technician": {
"api_key": {
"add": {
"success": "API-Schlüssel für {} wurde erstellt: {}"
},
"get": "API-Schlüssel für {}: {}",
"remove": {
"not_found": "API-Schlüssel konnte nicht gefunden werden!",
"success": "API-Schlüssel wurde entfernt :D"
}
},
"log_message": "Hier sind deine Logdateien! :)",
"restart_message": "Bin gleich wieder da :D",
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, Euer Freund. Lebt lange und in Frieden :)",
"log_message": "Hier sind deine Logdateien! :)"
}
},
"api": {
"mail": {
"automatic_mail": "\n\nDies ist eine automatische E-Mail.\nGesendet von {}-{}@{}"
},
"api": {
"test_mail": {
"subject": "Krümmelmonster Web Interface Test-Mail",
"message": "Dies ist eine Test-Mail vom Krümmelmonster Web Interface\nGesendet von {}-{}"
}
},
"auth": {
"confirmation": {
"subject": "E-Mail für {} {} bestätigen",
"message": "Öffne den Link um die E-Mail zu bestätigen:\n{}auth/register/{}"
},
"forgot_password": {
"subject": "Passwort für {} {} zurücksetzen",
"message": "Öffne den Link um das Passwort zu ändern:\n{}auth/forgot-password/{}"
}
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, euer Freund. Lebt lange und in Frieden :)"
}
}
}

View File

@ -15,7 +15,7 @@ __title__ = "bot_api"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -52,17 +52,13 @@ class AuthServiceABC(ABC):
pass
@abstractmethod
async def add_auth_user_async(self, user_dto: AuthUserDTO):
def add_auth_user(self, user_dto: AuthUserDTO):
pass
@abstractmethod
async def add_auth_user_by_oauth_async(self, dto: OAuthDTO):
pass
@abstractmethod
async def add_auth_user_by_discord_async(self, user_dto: AuthUserDTO, dc_id: int) -> OAuthDTO:
pass
@abstractmethod
async def update_user_async(self, update_user_dto: UpdateAuthUserDTO):
pass
@ -83,12 +79,16 @@ class AuthServiceABC(ABC):
async def verify_login(self, token_str: str) -> bool:
pass
@abstractmethod
def verify_api_key(self, api_key: str) -> bool:
pass
@abstractmethod
async def login_async(self, user_dto: AuthUserDTO) -> TokenDTO:
pass
@abstractmethod
async def login_discord_async(self, oauth_dto: AuthUserDTO) -> TokenDTO:
async def login_discord_async(self, oauth_dto: AuthUserDTO, dc_id: int) -> TokenDTO:
pass
@abstractmethod

View File

@ -1,4 +1,3 @@
import re
import sys
import textwrap
import uuid
@ -16,7 +15,6 @@ from werkzeug.exceptions import NotFound
from bot_api.configuration.api_settings import ApiSettings
from bot_api.configuration.authentication_settings import AuthenticationSettings
from bot_api.configuration.frontend_settings import FrontendSettings
from bot_api.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException
from bot_api.logging.api_logger import ApiLogger
@ -30,7 +28,6 @@ class Api(Flask):
logger: ApiLogger,
services: ServiceProviderABC,
api_settings: ApiSettings,
frontend_settings: FrontendSettings,
auth_settings: AuthenticationSettings,
*args,
**kwargs,
@ -146,20 +143,13 @@ class Api(Flask):
return response
def start(self):
self._logger.info(
__name__,
f"Starting API {self._api_settings.host}:{self._api_settings.port}",
)
self._logger.info(__name__, f"Starting API {self._api_settings.host}:{self._api_settings.port}")
self._register_routes()
self.secret_key = CredentialManager.decrypt(self._auth_settings.secret_key)
# from waitress import serve
# https://docs.pylonsproject.org/projects/waitress/en/stable/arguments.html
# serve(self, host=self._apt_settings.host, port=self._apt_settings.port, threads=10, connection_limit=1000, channel_timeout=10)
wsgi.server(
eventlet.listen((self._api_settings.host, self._api_settings.port)),
self,
log_output=False,
)
wsgi.server(eventlet.listen((self._api_settings.host, self._api_settings.port)), self, log_output=False)
def on_connect(self):
self._logger.info(__name__, f"Client connected")

View File

@ -13,7 +13,7 @@ from bot_api.api import Api
from bot_api.api_thread import ApiThread
from bot_api.controller.auth_controller import AuthController
from bot_api.controller.auth_discord_controller import AuthDiscordController
from bot_api.controller.discord.server_controller import ServerController
from bot_api.controller.graphql_controller import GraphQLController
from bot_api.controller.gui_controller import GuiController
from bot_api.event.bot_api_on_ready_event import BotApiOnReadyEvent
from bot_api.service.auth_service import AuthService
@ -45,7 +45,7 @@ class ApiModule(ModuleABC):
services.add_transient(AuthDiscordController)
services.add_transient(GuiController)
services.add_transient(DiscordService)
services.add_transient(ServerController)
services.add_transient(GraphQLController)
# cpl-discord
self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent)

View File

@ -2,12 +2,9 @@ from cpl_core.application import ApplicationExtensionABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.dependency_injection import ServiceProviderABC
from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.configuration.authentication_settings import AuthenticationSettings
from bot_api.route.route import Route
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC
class AppApiExtension(ApplicationExtensionABC):
@ -19,7 +16,4 @@ class AppApiExtension(ApplicationExtensionABC):
if not feature_flags.get_flag(FeatureFlagsEnum.api_module):
return
auth_settings: AuthenticationSettings = config.get_configuration(AuthenticationSettings)
auth_users: AuthUserRepositoryABC = services.get_service(AuthUserRepositoryABC)
auth: AuthServiceABC = services.get_service(AuthServiceABC)
Route.init_authorize(auth_users, auth)
Route.init_authorize()

View File

@ -2,9 +2,9 @@
"ProjectSettings": {
"Name": "bot-api",
"Version": {
"Major": "0",
"Minor": "3",
"Micro": "1.post1"
"Major": "1",
"Minor": "0",
"Micro": "0"
},
"Author": "",
"AuthorEmail": "",

@ -1 +1 @@
Subproject commit e6046881b562982008583afa973b39ff08b6a3c7
Subproject commit c712f856ebe30c71ac0b144045599ed2f91a1cba

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -6,8 +6,6 @@ from flask import request, jsonify, Response
from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.api import Api
from bot_api.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException
from bot_api.filter.auth_user_select_criteria import AuthUserSelectCriteria
from bot_api.json_processor import JSONProcessor
from bot_api.logging.api_logger import ApiLogger
@ -73,7 +71,7 @@ class AuthController:
@Route.post(f"{BasePath}/register")
async def register(self):
dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True))
await self._auth_service.add_auth_user_async(dto)
self._auth_service.add_auth_user(dto)
return "", 200
@Route.post(f"{BasePath}/register-by-id/<id>")
@ -131,7 +129,6 @@ class AuthController:
return "", 200
@Route.post(f"{BasePath}/refresh")
@Route.authorize
async def refresh(self) -> Response:
dto: TokenDTO = JSONProcessor.process(TokenDTO, request.get_json(force=True, silent=True))
result = await self._auth_service.refresh_async(dto)

View File

@ -8,7 +8,7 @@ from cpl_core.utils import CredentialManager
from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe
from flask import jsonify, Response
from flask import request, session
from flask import request
from requests_oauthlib import OAuth2Session
from bot_api.abc.auth_service_abc import AuthServiceABC
@ -16,10 +16,8 @@ from bot_api.api import Api
from bot_api.configuration.discord_authentication_settings import (
DiscordAuthenticationSettings,
)
from bot_api.json_processor import JSONProcessor
from bot_api.logging.api_logger import ApiLogger
from bot_api.model.auth_user_dto import AuthUserDTO
from bot_api.model.o_auth_dto import OAuthDTO
from bot_api.route.route import Route
from bot_data.model.auth_role_enum import AuthRoleEnum
@ -59,7 +57,7 @@ class AuthDiscordController:
self._bot.user.id,
redirect_uri=self._auth_settings.redirect_url,
state=request.args.get("state"),
scope=self._auth_settings.scope,
scope=self._auth_settings.scope.to_list(),
)
token = discord.fetch_token(
self._auth_settings.token_url,
@ -74,28 +72,11 @@ class AuthDiscordController:
oauth = OAuth2Session(
self._bot.user.id,
redirect_uri=self._auth_settings.redirect_url,
scope=self._auth_settings.scope,
scope=self._auth_settings.scope.to_list(),
)
login_url, state = oauth.authorization_url(self._auth_settings.auth_url)
return jsonify({"loginUrl": login_url})
@Route.get(f"{BasePath}/create-user")
async def discord_create_user(self) -> Response:
response = self._get_user_from_discord_response()
result = await self._auth_service.add_auth_user_by_discord_async(
AuthUserDTO(
0,
response["username"],
response["discriminator"],
response["email"],
str(uuid.uuid4()),
None,
AuthRoleEnum.normal,
),
response["id"],
)
return jsonify(result.to_dict())
@Route.get(f"{BasePath}/login")
async def discord_login(self) -> Response:
response = self._get_user_from_discord_response()
@ -109,5 +90,5 @@ class AuthDiscordController:
AuthRoleEnum.normal,
)
result = await self._auth_service.login_discord_async(dto)
result = await self._auth_service.login_discord_async(dto, response["id"])
return jsonify(result.to_dict())

View File

@ -1,67 +0,0 @@
from cpl_core.configuration import ConfigurationABC
from cpl_core.environment import ApplicationEnvironmentABC
from cpl_core.mailing import EMailClientABC, EMailClientSettings
from cpl_translation import TranslatePipe
from flask import Response, jsonify, request
from bot_api.api import Api
from bot_api.filter.discord.server_select_criteria import ServerSelectCriteria
from bot_api.json_processor import JSONProcessor
from bot_api.logging.api_logger import ApiLogger
from bot_api.route.route import Route
from bot_api.service.discord_service import DiscordService
from bot_data.model.auth_role_enum import AuthRoleEnum
class ServerController:
BasePath = f"/api/discord/server"
def __init__(
self,
config: ConfigurationABC,
env: ApplicationEnvironmentABC,
logger: ApiLogger,
t: TranslatePipe,
api: Api,
mail_settings: EMailClientSettings,
mailer: EMailClientABC,
discord_service: DiscordService,
):
self._config = config
self._env = env
self._logger = logger
self._t = t
self._api = api
self._mail_settings = mail_settings
self._mailer = mailer
self._discord_service = discord_service
@Route.get(f"{BasePath}/get/servers")
@Route.authorize(role=AuthRoleEnum.admin)
async def get_all_servers(self) -> Response:
result = await self._discord_service.get_all_servers()
result = result.select(lambda x: x.to_dict()).to_list()
return jsonify(result)
@Route.get(f"{BasePath}/get/servers-by-user")
@Route.authorize
async def get_all_servers_by_user(self) -> Response:
result = await self._discord_service.get_all_servers_by_user()
result = result.select(lambda x: x.to_dict()).to_list()
return jsonify(result)
@Route.post(f"{BasePath}/get/filtered")
@Route.authorize
async def get_filtered_servers(self) -> Response:
dto: ServerSelectCriteria = JSONProcessor.process(
ServerSelectCriteria, request.get_json(force=True, silent=True)
)
result = await self._discord_service.get_filtered_servers_async(dto)
result.result = result.result.select(lambda x: x.to_dict()).to_list()
return jsonify(result.to_dict())
@Route.get(f"{BasePath}/get/<id>")
@Route.authorize
async def get_server_by_id(self, id: int) -> Response:
result = await self._discord_service.get_server_by_id_async(id).to_list()
return jsonify(result.to_dict())

View File

@ -0,0 +1,44 @@
from ariadne import graphql_sync
from ariadne.constants import PLAYGROUND_HTML
from cpl_core.configuration import ConfigurationABC
from cpl_core.environment import ApplicationEnvironmentABC
from flask import request, jsonify
from bot_api.logging.api_logger import ApiLogger
from bot_api.route.route import Route
from bot_graphql.schema import Schema
class GraphQLController:
BasePath = f"/api/graphql"
def __init__(
self,
config: ConfigurationABC,
env: ApplicationEnvironmentABC,
logger: ApiLogger,
schema: Schema,
):
self._config = config
self._env = env
self._logger = logger
self._schema = schema
@Route.get(f"{BasePath}/playground")
@Route.authorize(skip_in_dev=True)
async def playground(self):
if self._env.environment_name != "development":
return "", 403
return PLAYGROUND_HTML, 200
@Route.post(f"{BasePath}")
@Route.authorize(by_api_key=True)
async def graphql(self):
data = request.get_json()
# Note: Passing the request to the context is optional.
# In Flask, the current request is always accessible as flask.request
success, result = graphql_sync(self._schema.schema, data, context_value=request)
return jsonify(result), 200 if success else 400

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.event"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -4,7 +4,6 @@ from werkzeug.exceptions import Unauthorized
class ServiceErrorCode(Enum):
Unknown = 0
InvalidDependencies = 1

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.model"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -1,6 +1,10 @@
from datetime import datetime
from typing import Optional
from cpl_query.extension import List
from bot_api.abc.dto_abc import DtoABC
from bot_api.model.user_dto import UserDTO
from bot_data.model.auth_role_enum import AuthRoleEnum
@ -14,6 +18,9 @@ class AuthUserDTO(DtoABC):
password: str = None,
confirmation_id: Optional[str] = None,
auth_role: AuthRoleEnum = None,
users: List[UserDTO] = None,
created_at: datetime = None,
modified_at: datetime = None,
):
DtoABC.__init__(self)
@ -24,6 +31,13 @@ class AuthUserDTO(DtoABC):
self._password = password
self._is_confirmed = confirmation_id is None
self._auth_role = auth_role
self._created_at = created_at
self._modified_at = modified_at
if users is None:
self._users = List(UserDTO)
else:
self._users = users
@property
def id(self) -> int:
@ -77,6 +91,18 @@ class AuthUserDTO(DtoABC):
def auth_role(self, value: AuthRoleEnum):
self._auth_role = value
@property
def users(self) -> List[UserDTO]:
return self._users
@property
def created_at(self) -> datetime:
return self._created_at
@property
def modified_at(self) -> datetime:
return self._modified_at
def from_dict(self, values: dict):
self._id = values["id"]
self._first_name = values["firstName"]
@ -85,6 +111,15 @@ class AuthUserDTO(DtoABC):
self._password = values["password"]
self._is_confirmed = values["isConfirmed"]
self._auth_role = AuthRoleEnum(values["authRole"])
if "users" in values:
self._users = List(UserDTO)
for u in values["users"]:
user = UserDTO()
user.from_dict(u)
self._users.add(user)
self._created_at = values["createdAt"]
self._modified_at = values["modifiedAt"]
def to_dict(self) -> dict:
return {
@ -95,4 +130,7 @@ class AuthUserDTO(DtoABC):
"password": self._password,
"isConfirmed": self._is_confirmed,
"authRole": self._auth_role.value,
"users": self._users.select(lambda u: u.to_dict()).to_list(),
"createdAt": self._created_at,
"modifiedAt": self._modified_at,
}

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -1,16 +1,13 @@
import traceback
from cpl_core.console import Console
from bot_api.abc.dto_abc import DtoABC
class TokenDTO(DtoABC):
def __init__(self, token: str, refresh_token: str):
def __init__(self, token: str, refresh_token: str, first_login: bool = False):
DtoABC.__init__(self)
self._token = token
self._refresh_token = refresh_token
self._first_login = first_login
@property
def token(self) -> str:
@ -20,9 +17,14 @@ class TokenDTO(DtoABC):
def refresh_token(self) -> str:
return self._refresh_token
@property
def first_login(self) -> bool:
return self._first_login
def from_dict(self, values: dict):
self._token = values["token"]
self._refresh_token = values["refreshToken"]
self._first_login = values["firstLogin"]
def to_dict(self) -> dict:
return {"token": self._token, "refreshToken": self._refresh_token}
return {"token": self._token, "refreshToken": self._refresh_token, "firstLogin": self._first_login}

View File

@ -0,0 +1,76 @@
from typing import Optional
from bot_api.abc.dto_abc import DtoABC
from bot_data.model.server import Server
class UserDTO(DtoABC):
def __init__(
self,
id: int = None,
dc_id: int = None,
xp: int = None,
server: Optional[Server] = None,
is_technician: Optional[bool] = None,
is_admin: Optional[bool] = None,
is_moderator: Optional[bool] = None,
):
DtoABC.__init__(self)
self._user_id = id
self._discord_id = dc_id
self._xp = xp
self._server = server
self._is_technician = is_technician
self._is_admin = is_admin
self._is_moderator = is_moderator
@property
def user_id(self) -> int:
return self._user_id
@property
def discord_id(self) -> int:
return self._discord_id
@property
def xp(self) -> int:
return self._xp
@xp.setter
def xp(self, value: int):
self._xp = value
@property
def server(self) -> Optional[Server]:
return self._server
@property
def is_technician(self) -> bool:
return self._is_technician if self._is_technician is not None else False
@property
def is_admin(self) -> bool:
return self._is_admin if self._is_admin is not None else False
@property
def is_moderator(self) -> bool:
return self._is_moderator if self._is_moderator is not None else False
def from_dict(self, values: dict):
self._user_id = values["id"]
self._discord_id = values["dcId"]
self._xp = values["xp"]
self._server = values["server"]
def to_dict(self) -> dict:
return {
"id": self._user_id,
"dcId": self._discord_id,
"xp": self._xp,
"server": self._server.id,
"isTechnician": self.is_technician,
"isAdmin": self.is_admin,
"isModerator": self.is_moderator,
}

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.route"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -1,7 +1,9 @@
import functools
from functools import wraps
from typing import Optional, Callable
from typing import Optional, Callable, Union
from cpl_core.dependency_injection import ServiceProviderABC
from cpl_core.environment import ApplicationEnvironmentABC
from flask import request, jsonify
from flask_cors import cross_origin
@ -11,6 +13,7 @@ from bot_api.exception.service_exception import ServiceException
from bot_api.model.error_dto import ErrorDTO
from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC
from bot_data.model.auth_role_enum import AuthRoleEnum
from bot_data.model.auth_user import AuthUser
class Route:
@ -18,23 +21,77 @@ class Route:
_auth_users: Optional[AuthUserRepositoryABC] = None
_auth: Optional[AuthServiceABC] = None
_env = "production"
@classmethod
def init_authorize(cls, auth_users: AuthUserRepositoryABC, auth: AuthServiceABC):
@ServiceProviderABC.inject
def init_authorize(cls, env: ApplicationEnvironmentABC, auth_users: AuthUserRepositoryABC, auth: AuthServiceABC):
cls._auth_users = auth_users
cls._auth = auth
cls._env = env.environment_name
@classmethod
def authorize(cls, f: Callable = None, role: AuthRoleEnum = None):
def get_user(cls) -> Optional[Union[str, AuthUser]]:
token = None
api_key = None
authorization = request.headers.get("Authorization").split()
match authorization[0]:
case "Bearer":
token = authorization[1]
case "API-Key":
api_key = authorization[1]
if api_key is not None:
return "system"
if token is None:
return None
jwt = cls._auth.decode_token(token)
user = cls._auth_users.get_auth_user_by_email(jwt["email"])
return user
@classmethod
def authorize(cls, f: Callable = None, role: AuthRoleEnum = None, skip_in_dev=False, by_api_key=False):
if f is None:
return functools.partial(cls.authorize, role=role)
return functools.partial(cls.authorize, role=role, skip_in_dev=skip_in_dev, by_api_key=by_api_key)
@wraps(f)
async def decorator(*args, **kwargs):
if skip_in_dev and cls._env == "development":
return await f(*args, **kwargs)
token = None
api_key = None
if "Authorization" in request.headers:
bearer = request.headers.get("Authorization")
token = bearer.split()[1]
if " " not in request.headers.get("Authorization"):
ex = ServiceException(ServiceErrorCode.Unauthorized, f"Token not set")
error = ErrorDTO(ex.error_code, ex.message)
return jsonify(error.to_dict()), 401
authorization = request.headers.get("Authorization").split()
match authorization[0]:
case "Bearer":
token = authorization[1]
case "API-Key":
api_key = authorization[1]
if api_key is not None:
valid = False
try:
valid = cls._auth.verify_api_key(api_key)
except ServiceException as e:
error = ErrorDTO(e.error_code, e.message)
return jsonify(error.to_dict()), 403
except Exception as e:
return jsonify(e), 500
if not valid:
ex = ServiceException(ServiceErrorCode.Unauthorized, f"API-Key invalid")
error = ErrorDTO(ex.error_code, ex.message)
return jsonify(error.to_dict()), 401
return await f(*args, **kwargs)
if token is None:
ex = ServiceException(ServiceErrorCode.Unauthorized, f"Token not set")

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.service"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -31,9 +31,11 @@ from bot_api.model.reset_password_dto import ResetPasswordDTO
from bot_api.model.token_dto import TokenDTO
from bot_api.model.update_auth_user_dto import UpdateAuthUserDTO
from bot_api.transformer.auth_user_transformer import AuthUserTransformer as AUT
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.abc.user_repository_abc import UserRepositoryABC
from bot_data.model.api_key import ApiKey
from bot_data.model.auth_role_enum import AuthRoleEnum
from bot_data.model.auth_user import AuthUser
from bot_data.model.auth_user_users_relation import AuthUserUsersRelation
@ -49,9 +51,9 @@ class AuthService(AuthServiceABC):
bot: DiscordBotServiceABC,
db: DatabaseContextABC,
auth_users: AuthUserRepositoryABC,
api_keys: ApiKeyRepositoryABC,
users: UserRepositoryABC,
servers: ServerRepositoryABC,
# mailer: MailThread,
mailer: EMailClientABC,
t: TranslatePipe,
auth_settings: AuthenticationSettings,
@ -64,6 +66,7 @@ class AuthService(AuthServiceABC):
self._bot = bot
self._db = db
self._auth_users = auth_users
self._api_keys = api_keys
self._users = users
self._servers = servers
self._mailer = mailer
@ -77,11 +80,19 @@ class AuthService(AuthServiceABC):
@staticmethod
def _is_email_valid(email: str) -> bool:
if email is None:
raise False
if re.fullmatch(_email_regex, email) is not None:
return True
return False
def _get_api_key_str(self, api_key: ApiKey) -> str:
return hashlib.sha256(
f"{api_key.identifier}:{api_key.key}+{self._auth_settings.secret_key}".encode("utf-8")
).hexdigest()
def generate_token(self, user: AuthUser) -> str:
token = jwt.encode(
payload={
@ -215,7 +226,7 @@ class AuthService(AuthServiceABC):
user = self._auth_users.find_auth_user_by_email(email)
return AUT.to_dto(user) if user is not None else None
async def add_auth_user_async(self, user_dto: AuthUserDTO):
def add_auth_user(self, user_dto: AuthUserDTO):
db_user = self._auth_users.find_auth_user_by_email(user_dto.email)
if db_user is not None:
raise ServiceException(ServiceErrorCode.InvalidUser, "User already exists")
@ -264,51 +275,6 @@ class AuthService(AuthServiceABC):
self._db.save_changes()
async def add_auth_user_by_discord_async(self, user_dto: AuthUserDTO, dc_id: int) -> OAuthDTO:
db_auth_user = self._auth_users.find_auth_user_by_email(user_dto.email)
# user exists
if db_auth_user is not None and db_auth_user.users.count() > 0:
# raise ServiceException(ServiceErrorCode.InvalidUser, 'User already exists')
self._logger.debug(__name__, f"Discord user already exists")
return OAuthDTO(AUT.to_dto(db_auth_user), None)
# user exists but discord user id not set
elif db_auth_user is not None and db_auth_user.users.count() == 0:
self._logger.debug(__name__, f"Auth user exists but not linked with discord")
# users = self._users.get_users_by_discord_id(user_dto.user_id)
# add auth_user to user refs
db_auth_user.oauth_id = None
else:
# user does not exists
self._logger.debug(__name__, f"Auth user does not exist")
try:
user_dto.user_id = self._users.get_users_by_discord_id(user_dto.user_id).single().user_id
except Exception as e:
self._logger.error(__name__, f"User not found")
user_dto.user_id = None
await self.add_auth_user_async(user_dto)
db_auth_user = self._auth_users.get_auth_user_by_email(user_dto.email)
db_auth_user.oauth_id = uuid.uuid4()
for g in self._bot.guilds:
member = g.get_member(int(dc_id))
if member is None:
continue
server = self._servers.get_server_by_discord_id(g.id)
users = self._users.get_users_by_discord_id(dc_id)
for user in users:
if user.server.server_id != server.server_id:
continue
self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_auth_user, user))
self._auth_users.update_auth_user(db_auth_user)
self._db.save_changes()
return OAuthDTO(AUT.to_dto(db_auth_user), db_auth_user.oauth_id)
async def update_user_async(self, update_user_dto: UpdateAuthUserDTO):
if update_user_dto is None:
raise ServiceException(ServiceErrorCode.InvalidData, f"User is empty")
@ -478,6 +444,18 @@ class AuthService(AuthServiceABC):
return True
def verify_api_key(self, api_key: str) -> bool:
try:
keys = self._api_keys.get_api_keys().select(self._get_api_key_str)
if not keys.contains(api_key):
raise ServiceException(ServiceErrorCode.InvalidData, "API-Key invalid")
except Exception as e:
self._logger.error(__name__, f"API-Key invalid", e)
return False
return True
async def login_async(self, user_dto: AuthUser) -> TokenDTO:
if user_dto is None:
raise ServiceException(ServiceErrorCode.InvalidData, "User not set")
@ -490,6 +468,9 @@ class AuthService(AuthServiceABC):
if db_user.password != user_dto.password:
raise ServiceException(ServiceErrorCode.InvalidUser, "Wrong password")
if db_user.confirmation_id is not None:
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
token = self.generate_token(db_user)
refresh_token = self._create_and_save_refresh_token(db_user)
if db_user.forgot_password_id is not None:
@ -498,23 +479,34 @@ class AuthService(AuthServiceABC):
self._db.save_changes()
return TokenDTO(token, refresh_token)
async def login_discord_async(self, user_dto: AuthUserDTO) -> TokenDTO:
async def login_discord_async(self, user_dto: AuthUserDTO, dc_id: int) -> TokenDTO:
if user_dto is None:
raise ServiceException(ServiceErrorCode.InvalidData, "User not set")
members = self._users.get_users_by_discord_id(dc_id)
if members.count() == 0:
raise ServiceException(ServiceErrorCode.InvalidUser, f"Member not found")
added_user = False
db_user = self._auth_users.find_auth_user_by_email(user_dto.email)
if db_user is None:
await self.add_auth_user_async(user_dto)
# raise ServiceException(ServiceErrorCode.InvalidUser, f'User not found')
self.add_auth_user(user_dto)
added_user = True
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
if db_user.users.count() == 0:
members.for_each(lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x)))
if db_user.confirmation_id is not None and not added_user:
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
token = self.generate_token(db_user)
refresh_token = self._create_and_save_refresh_token(db_user)
if db_user.forgot_password_id is not None:
db_user.forgot_password_id = None
self._db.save_changes()
return TokenDTO(token, refresh_token)
return TokenDTO(token, refresh_token, first_login=added_user)
async def refresh_async(self, token_dto: TokenDTO) -> TokenDTO:
if token_dto is None:

View File

@ -2,7 +2,6 @@ from typing import Optional
from cpl_discord.service import DiscordBotServiceABC
from cpl_query.extension import List
from flask import jsonify
from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.exception.service_error_code_enum import ServiceErrorCode
@ -10,7 +9,6 @@ from bot_api.exception.service_exception import ServiceException
from bot_api.filter.discord.server_select_criteria import ServerSelectCriteria
from bot_api.model.discord.server_dto import ServerDTO
from bot_api.model.discord.server_filtered_result_dto import ServerFilteredResultDTO
from bot_api.model.error_dto import ErrorDTO
from bot_api.transformer.server_transformer import ServerTransformer
from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
@ -35,7 +33,7 @@ class DiscordService:
self._users = users
def _to_dto(self, x: Server) -> Optional[ServerDTO]:
guild = self._bot.get_guild(x.discord_server_id)
guild = self._bot.get_guild(x.discord_id)
if guild is None:
return ServerTransformer.to_dto(x, "", 0, None)
@ -55,8 +53,8 @@ class DiscordService:
if role != AuthRoleEnum.admin:
auth_user = self._auth_users.find_auth_user_by_email(token["email"])
if auth_user is not None:
user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.server_id)
servers = servers.where(lambda x: x.server_id in user_ids)
user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.id)
servers = servers.where(lambda x: x.id in user_ids)
servers = List(ServerDTO, servers)
return servers.select(self._to_dto).where(lambda x: x.name != "")
@ -72,8 +70,8 @@ class DiscordService:
if role != AuthRoleEnum.admin:
auth_user = self._auth_users.find_auth_user_by_email(token["email"])
if auth_user is not None:
user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.server_id)
filtered_result.result = filtered_result.result.where(lambda x: x.server_id in user_ids)
user_ids = auth_user.users.select(lambda x: x.server is not None and x.server.id)
filtered_result.result = filtered_result.result.where(lambda x: x.id in user_ids)
servers: List = filtered_result.result.select(self._to_dto).where(lambda x: x.name != "")
result = List(ServerDTO, servers)
@ -87,7 +85,7 @@ class DiscordService:
async def get_server_by_id_async(self, id: int) -> ServerDTO:
server = self._servers.get_server_by_id(id)
guild = self._bot.get_guild(server.discord_server_id)
guild = self._bot.get_guild(server.discord_id)
server_dto = ServerTransformer.to_dto(server, guild.name, guild.member_count, guild.icon)
return server_dto

View File

@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -1,9 +1,16 @@
from datetime import datetime, timezone
from datetime import datetime
from cpl_core.dependency_injection import ServiceProviderABC
from cpl_discord.service import DiscordBotServiceABC
from cpl_query.extension import List
from bot_api.abc.transformer_abc import TransformerABC
from bot_api.model.auth_user_dto import AuthUserDTO
from bot_api.model.user_dto import UserDTO
from bot_data.model.auth_role_enum import AuthRoleEnum
from bot_data.model.auth_user import AuthUser
from bot_data.model.user import User
from modules.permission.abc.permission_service_abc import PermissionServiceABC
class AuthUserTransformer(TransformerABC):
@ -25,7 +32,28 @@ class AuthUserTransformer(TransformerABC):
)
@staticmethod
def to_dto(db: AuthUser, password: str = None) -> AuthUserDTO:
@ServiceProviderABC.inject
def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id)
member = guild.get_member(user.discord_id)
return permissions.is_member_technician(member)
@staticmethod
@ServiceProviderABC.inject
def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id)
member = guild.get_member(user.discord_id)
return permissions.is_member_admin(member)
@staticmethod
@ServiceProviderABC.inject
def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id)
member = guild.get_member(user.discord_id)
return permissions.is_member_moderator(member)
@classmethod
def to_dto(cls, db: AuthUser, password: str = None) -> AuthUserDTO:
return AuthUserDTO(
db.id,
db.first_name,
@ -34,4 +62,20 @@ class AuthUserTransformer(TransformerABC):
"" if password is None else password,
db.confirmation_id,
db.auth_role,
List(
UserDTO,
db.users.select(
lambda u: UserDTO(
u.id,
u.discord_id,
u.xp,
u.server,
cls._is_technician(u),
cls._is_admin(u),
cls._is_moderator(u),
)
),
),
db.created_at,
db.modified_at,
)

View File

@ -15,8 +15,8 @@ class ServerTransformer(TransformerABC):
@staticmethod
def to_dto(db: Server, name: str, member_count: int, icon_url: Optional[discord.Asset]) -> ServerDTO:
return ServerDTO(
db.server_id,
db.discord_server_id,
db.id,
db.discord_id,
name,
member_count,
icon_url.url if icon_url is not None else None,

View File

@ -15,7 +15,7 @@ __title__ = "bot_core"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -2,9 +2,9 @@
"ProjectSettings": {
"Name": "bot-core",
"Version": {
"Major": "0",
"Minor": "3",
"Micro": "1.post1"
"Major": "1",
"Minor": "0",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -10,12 +10,12 @@ class FeatureFlagsEnum(Enum):
boot_log_module = "BootLogModule"
core_module = "CoreModule"
core_extension_module = "CoreExtensionModule"
data_module = ("DataModule",)
database_module = ("DatabaseModule",)
data_module = "DataModule"
database_module = "DatabaseModule"
level_module = "LevelModule"
moderator_module = "ModeratorModule"
permission_module = "PermissionModule"
stats_module = "StatsModule"
# features
api_only = "ApiOnly"
presence = "Presence"
version_in_presence = "VersionInPresence"

View File

@ -1,5 +1,4 @@
import traceback
from typing import Optional, Callable
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
@ -24,10 +23,10 @@ class FeatureFlagsSettings(ConfigurationModelABC):
FeatureFlagsEnum.database_module.value: True, # 02.10.2022 #48
FeatureFlagsEnum.moderator_module.value: False, # 02.10.2022 #48
FeatureFlagsEnum.permission_module.value: True, # 02.10.2022 #48
FeatureFlagsEnum.stats_module.value: True, # 08.11.2022 #46
# features
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
FeatureFlagsEnum.version_in_presence.value: False, # 21.03.2023 #253
}
def get_flag(self, key: FeatureFlagsEnum) -> bool:

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.events"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_core.service"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -60,28 +60,28 @@ class ClientUtilsService(ClientUtilsABC):
def received_command(self, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id)
client.received_command_count += 1
self._clients.update_client(client)
self._db.save_changes()
def moved_user(self, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id)
client.moved_users_count += 1
self._clients.update_client(client)
self._db.save_changes()
def moved_users(self, guild_id: int, count: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id)
client.moved_users_count += count
self._clients.update_client(client)
self._db.save_changes()
def get_client(self, dc_ic: int, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.id)
return client
async def check_if_bot_is_ready_yet(self) -> bool:
@ -111,7 +111,11 @@ class ClientUtilsService(ClientUtilsABC):
import bot
name = self._t.transform(t_key).format(bot.__version__)
if self._feature_flags.get_flag(FeatureFlagsEnum.version_in_presence):
name = f"{bot.__version__} {self._t.transform(t_key)}"
else:
name = self._t.transform(t_key)
await self._bot.change_presence(activity=discord.Game(name=name))
self._logger.info(__name__, f"Set presence {name}")
@ -138,7 +142,7 @@ class ClientUtilsService(ClientUtilsABC):
) -> bool:
umcph = None
try:
umcph = self._umcphs.find_user_message_count_per_hour_by_user_id_and_date(user.user_id, created_at)
umcph = self._umcphs.find_user_message_count_per_hour_by_user_id_and_date(user.id, created_at)
if umcph is None:
self._umcphs.add_user_message_count_per_hour(
UserMessageCountPerHour(
@ -151,7 +155,7 @@ class ClientUtilsService(ClientUtilsABC):
self._db.save_changes()
umcph = self._umcphs.get_user_message_count_per_hour_by_user_id_and_date(user.user_id, created_at)
umcph = self._umcphs.get_user_message_count_per_hour_by_user_id_and_date(user.id, created_at)
except Exception as e:
self._logger.error(
__name__,
@ -183,7 +187,7 @@ class ClientUtilsService(ClientUtilsABC):
def get_ontime_for_user(self, user: User) -> float:
return round(
self._user_joined_voice_channel.get_user_joined_voice_channels_by_user_id(user.user_id)
self._user_joined_voice_channel.get_user_joined_voice_channels_by_user_id(user.id)
.where(lambda x: x.leaved_on is not None and x.joined_on is not None)
.sum(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600),
2,

View File

@ -15,7 +15,7 @@ __title__ = "bot_data"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -0,0 +1,39 @@
from abc import ABC, abstractmethod
from cpl_query.extension import List
from bot_data.model.api_key import ApiKey
class ApiKeyRepositoryABC(ABC):
@abstractmethod
def __init__(self):
pass
@abstractmethod
def get_api_keys(self) -> List[ApiKey]:
pass
@abstractmethod
def get_api_key(self, identifier: str, key: str) -> ApiKey:
pass
@abstractmethod
def get_api_key_by_id(self, id: int) -> ApiKey:
pass
@abstractmethod
def get_api_key_by_key(self, key: str) -> ApiKey:
pass
@abstractmethod
def add_api_key(self, api_key: ApiKey):
pass
@abstractmethod
def update_api_key(self, api_key: ApiKey):
pass
@abstractmethod
def delete_api_key(self, api_key: ApiKey):
pass

View File

@ -2,6 +2,7 @@ from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from bot_data.model.client import Client
@ -22,6 +23,10 @@ class ClientRepositoryABC(ABC):
def get_client_by_discord_id(self, discord_id: int) -> Client:
pass
@abstractmethod
def get_clients_by_server_id(self, server_id: int) -> List[Client]:
pass
@abstractmethod
def find_client_by_discord_id(self, discord_id: int) -> Optional[Client]:
pass

View File

@ -0,0 +1,39 @@
from abc import ABC, abstractmethod
from cpl_query.extension import List
from bot_data.model.game_server import GameServer
class GameServerRepositoryABC(ABC):
@abstractmethod
def __init__(self):
pass
@abstractmethod
def get_game_servers(self) -> List[GameServer]:
pass
@abstractmethod
def get_game_server_by_id(self, id: int) -> GameServer:
pass
@abstractmethod
def get_game_servers_by_server_id(self, id: int) -> List[GameServer]:
pass
@abstractmethod
def get_game_server_by_api_key_id(self, id: int) -> GameServer:
pass
@abstractmethod
def add_game_server(self, game_server: GameServer):
pass
@abstractmethod
def update_game_server(self, game_server: GameServer):
pass
@abstractmethod
def delete_game_server(self, game_server: GameServer):
pass

View File

@ -0,0 +1,27 @@
from abc import ABC, abstractmethod
from datetime import datetime
class HistoryTableABC(ABC):
@abstractmethod
def __init__(self):
self._id = 0
self._deleted = False
self._date_from = datetime.now().isoformat()
self._date_to = datetime.now().isoformat()
@property
def id(self) -> int:
return self._id
@property
def deleted(self) -> bool:
return self._deleted
@property
def date_from(self) -> str:
return self._date_from
@property
def date_to(self) -> str:
return self._date_to

View File

@ -3,6 +3,7 @@ from abc import ABC, abstractmethod
class MigrationABC(ABC):
name = None
prio = 0
@abstractmethod
def __init__(self):

View File

@ -1,44 +0,0 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from bot_data.model.statistic import Statistic
class StatisticRepositoryABC(ABC):
@abstractmethod
def __init__(self):
pass
@abstractmethod
def get_statistics(self) -> List[Statistic]:
pass
@abstractmethod
def get_statistics_by_server_id(self, server_id: int) -> List[Statistic]:
pass
@abstractmethod
def get_statistic_by_id(self, id: int) -> Statistic:
pass
@abstractmethod
def get_statistic_by_name(self, name: str, server_id: int) -> Statistic:
pass
@abstractmethod
def find_statistic_by_name(self, name: str, server_id: int) -> Optional[Statistic]:
pass
@abstractmethod
def add_statistic(self, statistic: Statistic):
pass
@abstractmethod
def update_statistic(self, statistic: Statistic):
pass
@abstractmethod
def delete_statistic(self, statistic: Statistic):
pass

View File

@ -0,0 +1,15 @@
from abc import abstractmethod
from cpl_core.database import TableABC
class TableWithIdABC(TableABC):
@abstractmethod
def __init__(self):
self.__init__()
self._id = 0
@property
def id(self) -> int:
return self._id

View File

@ -0,0 +1,47 @@
from abc import ABC, abstractmethod
from cpl_query.extension import List
from bot_data.model.user_game_ident import UserGameIdent
class UserGameIdentRepositoryABC(ABC):
@abstractmethod
def __init__(self):
pass
@abstractmethod
def get_user_game_idents(self) -> List[UserGameIdent]:
pass
@abstractmethod
def get_user_game_ident_by_id(self, id: int) -> UserGameIdent:
pass
@abstractmethod
def get_user_game_ident_by_ident(self, ident: str) -> UserGameIdent:
pass
@abstractmethod
def find_user_game_ident_by_ident(self, ident: str) -> UserGameIdent:
pass
@abstractmethod
def get_user_game_idents_by_user_id(self, user_id: int) -> List[UserGameIdent]:
pass
@abstractmethod
def add_user_game_ident(self, user_game_ident: UserGameIdent):
pass
@abstractmethod
def update_user_game_ident(self, user_game_ident: UserGameIdent):
pass
@abstractmethod
def delete_user_game_ident(self, user_game_ident: UserGameIdent):
pass
@abstractmethod
def delete_user_game_ident_by_user_id(self, user_id: int):
pass

View File

@ -0,0 +1,52 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from bot_data.model.user_joined_game_server import UserJoinedGameServer
class UserJoinedGameServerRepositoryABC(ABC):
@abstractmethod
def __init__(self):
pass
@abstractmethod
def get_user_joined_game_servers(self) -> List[UserJoinedGameServer]:
pass
@abstractmethod
def get_user_joined_game_server_by_id(self, id: int) -> UserJoinedGameServer:
pass
@abstractmethod
def get_user_joined_game_servers_by_user_id(self, user_id: int) -> List[UserJoinedGameServer]:
pass
@abstractmethod
def get_active_user_joined_game_server_by_user_id(self, user_id: int) -> UserJoinedGameServer:
pass
@abstractmethod
def find_active_user_joined_game_server_by_user_id(self, user_id: int) -> Optional[UserJoinedGameServer]:
pass
@abstractmethod
def find_active_user_joined_game_servers_by_user_id(self, user_id: int) -> List[Optional[UserJoinedGameServer]]:
pass
@abstractmethod
def add_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer):
pass
@abstractmethod
def update_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer):
pass
@abstractmethod
def delete_user_joined_game_server(self, user_joined_game_server: UserJoinedGameServer):
pass
@abstractmethod
def delete_user_joined_game_server_by_user_id(self, user_id: int):
pass

View File

@ -2,6 +2,7 @@ from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from bot_data.model.user_joined_server import UserJoinedServer
@ -18,6 +19,10 @@ class UserJoinedServerRepositoryABC(ABC):
def get_user_joined_server_by_id(self, id: int) -> UserJoinedServer:
pass
@abstractmethod
def get_user_joined_server_by_server_id(self, server_id: int) -> UserJoinedServer:
pass
@abstractmethod
def get_user_joined_servers_by_user_id(self, user_id: int) -> list[UserJoinedServer]:
pass

View File

@ -27,6 +27,10 @@ class UserRepositoryABC(ABC):
def get_users_by_discord_id(self, discord_id: int) -> List[User]:
pass
@abstractmethod
def get_users_by_server_id(self, server_id: int) -> List[User]:
pass
@abstractmethod
def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User:
pass

View File

@ -0,0 +1,35 @@
from abc import ABC, abstractmethod
from cpl_query.extension import List
from bot_data.model.user_warnings import UserWarnings
class UserWarningsRepositoryABC(ABC):
@abstractmethod
def __init__(self):
pass
@abstractmethod
def get_user_warnings(self) -> List[UserWarnings]:
pass
@abstractmethod
def get_user_warnings_by_id(self, id: int) -> UserWarnings:
pass
@abstractmethod
def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]:
pass
@abstractmethod
def add_user_warnings(self, user_warnings: UserWarnings):
pass
@abstractmethod
def update_user_warnings(self, user_warnings: UserWarnings):
pass
@abstractmethod
def delete_user_warnings(self, user_warnings: UserWarnings):
pass

View File

@ -2,9 +2,9 @@
"ProjectSettings": {
"Name": "bot-data",
"Version": {
"Major": "0",
"Minor": "3",
"Micro": "1.post1"
"Major": "1",
"Minor": "0",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -5,13 +5,16 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC
from bot_core.abc.module_abc import ModuleABC
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
from bot_data.abc.client_repository_abc import ClientRepositoryABC
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
from bot_data.abc.level_repository_abc import LevelRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.abc.statistic_repository_abc import StatisticRepositoryABC
from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC
from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
from bot_data.abc.user_joined_voice_channel_repository_abc import (
UserJoinedVoiceChannelRepositoryABC,
@ -20,14 +23,18 @@ from bot_data.abc.user_message_count_per_hour_repository_abc import (
UserMessageCountPerHourRepositoryABC,
)
from bot_data.abc.user_repository_abc import UserRepositoryABC
from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
from bot_data.service.api_key_repository_service import ApiKeyRepositoryService
from bot_data.service.auth_user_repository_service import AuthUserRepositoryService
from bot_data.service.auto_role_repository_service import AutoRoleRepositoryService
from bot_data.service.client_repository_service import ClientRepositoryService
from bot_data.service.game_server_repository_service import GameServerRepositoryService
from bot_data.service.known_user_repository_service import KnownUserRepositoryService
from bot_data.service.level_repository_service import LevelRepositoryService
from bot_data.service.seeder_service import SeederService
from bot_data.service.server_repository_service import ServerRepositoryService
from bot_data.service.statistic_repository_service import StatisticRepositoryService
from bot_data.service.user_game_ident_repository_service import UserGameIdentRepositoryService
from bot_data.service.user_joined_game_server_repository_service import UserJoinedGameServerRepositoryService
from bot_data.service.user_joined_server_repository_service import (
UserJoinedServerRepositoryService,
)
@ -38,6 +45,7 @@ from bot_data.service.user_message_count_per_hour_repository_service import (
UserMessageCountPerHourRepositoryService,
)
from bot_data.service.user_repository_service import UserRepositoryService
from bot_data.service.user_warnings_repository_service import UserWarningsRepositoryService
class DataModule(ModuleABC):
@ -48,6 +56,7 @@ class DataModule(ModuleABC):
pass
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
services.add_transient(ApiKeyRepositoryABC, ApiKeyRepositoryService)
services.add_transient(AuthUserRepositoryABC, AuthUserRepositoryService)
services.add_transient(ServerRepositoryABC, ServerRepositoryService)
services.add_transient(UserRepositoryABC, UserRepositoryService)
@ -55,12 +64,15 @@ class DataModule(ModuleABC):
services.add_transient(KnownUserRepositoryABC, KnownUserRepositoryService)
services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService)
services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService)
services.add_transient(UserJoinedGameServerRepositoryABC, UserJoinedGameServerRepositoryService)
services.add_transient(AutoRoleRepositoryABC, AutoRoleRepositoryService)
services.add_transient(LevelRepositoryABC, LevelRepositoryService)
services.add_transient(StatisticRepositoryABC, StatisticRepositoryService)
services.add_transient(UserWarningsRepositoryABC, UserWarningsRepositoryService)
services.add_transient(
UserMessageCountPerHourRepositoryABC,
UserMessageCountPerHourRepositoryService,
)
services.add_transient(GameServerRepositoryABC, GameServerRepositoryService)
services.add_transient(UserGameIdentRepositoryABC, UserGameIdentRepositoryService)
services.add_transient(SeederService)

View File

@ -6,7 +6,6 @@ from bot_core.logging.database_logger import DatabaseLogger
class DBContext(DatabaseContext):
def __init__(self, logger: DatabaseLogger):
self._logger = logger
DatabaseContext.__init__(self)

View File

@ -15,7 +15,7 @@ __title__ = "bot_data.migration"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

View File

@ -0,0 +1,38 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class ApiKeyMigration(MigrationABC):
name = "1.0.0_ApiKeyMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `ApiKeys` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`Identifier` VARCHAR(255) NOT NULL,
`Key` VARCHAR(255) NOT NULL,
`CreatorId` BIGINT NULL,
`CreatedAt` DATETIME(6),
`LastModifiedAt` DATETIME(6),
PRIMARY KEY(`Id`),
FOREIGN KEY (`CreatorId`) REFERENCES `Users`(`UserId`),
CONSTRAINT UC_Identifier_Key UNIQUE (`Identifier`,`Key`),
CONSTRAINT UC_Key UNIQUE (`Key`)
);
"""
)
)
def downgrade(self):
self._cursor.execute("DROP TABLE `ApiKeys`;")

View File

@ -4,7 +4,7 @@ from bot_data.db_context import DBContext
class AutoRoleFix1Migration(MigrationABC):
name = "0.3.0_AutoRoleMigration"
name = "0.3.0_AutoRoleFixMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)

View File

@ -0,0 +1,65 @@
import os
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class DBHistoryMigration(MigrationABC):
name = "1.0.0_DBHistoryMigration"
prio = 1
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def _exec(self, file: str):
path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts"
sql = open(f"{path}/{file}").read()
for statement in sql.split("\n\n"):
self._cursor.execute(statement + ";")
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._exec("api_keys.sql")
self._exec("auth_users.sql")
self._exec("auth_user_users_relation.sql")
self._exec("auto_role_rules.sql")
self._exec("auto_roles.sql")
self._exec("clients.sql")
self._exec("game_servers.sql")
self._exec("known_users.sql")
self._exec("levels.sql")
self._exec("servers.sql")
self._exec("user_game_idents.sql")
self._exec("user_joined_game_servers.sql")
self._exec("user_joined_servers.sql")
self._exec("user_joined_voice_channel.sql")
self._exec("user_message_count_per_hour.sql")
self._exec("users.sql")
self._exec("user_warnings.sql")
self._logger.debug(__name__, "Finished history upgrade")
def downgrade(self):
self._cursor.execute("DROP TABLE `ApiKeysHistory`;")
self._cursor.execute("DROP TABLE `AuthUsersHistory`;")
self._cursor.execute("DROP TABLE `AuthUserUsersRelationsHistory`;")
self._cursor.execute("DROP TABLE `AutoRoleRulesHistory`;")
self._cursor.execute("DROP TABLE `AutoRolesHistory`;")
self._cursor.execute("DROP TABLE `ClientsHistory`;")
self._cursor.execute("DROP TABLE `GameServersHistory`;")
self._cursor.execute("DROP TABLE `KnownUsersHistory`;")
self._cursor.execute("DROP TABLE `LevelsHistory`;")
self._cursor.execute("DROP TABLE `ServersHistory`;")
self._cursor.execute("DROP TABLE `UserGameIdentsHistory`;")
self._cursor.execute("DROP TABLE `UserJoinedGameServerHistory`;")
self._cursor.execute("DROP TABLE `UserJoinedServersHistory`;")
self._cursor.execute("DROP TABLE `UserJoinedVoiceChannelHistory`;")
self._cursor.execute("DROP TABLE `UserMessageCountPerHourHistory`;")
self._cursor.execute("DROP TABLE `UsersHistory`;")
self._cursor.execute("DROP TABLE `UserWarningsHistory`;")

View File

@ -0,0 +1,46 @@
ALTER TABLE `ApiKeys`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `ApiKeys`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `ApiKeysHistory`
(
`Id` BIGINT(20) NOT NULL,
`Identifier` VARCHAR(255) NOT NULL,
`Key` VARCHAR(255) NOT NULL,
`CreatorId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_ApiKeysUpdate`;
CREATE TRIGGER `TR_ApiKeysUpdate`
AFTER UPDATE
ON `ApiKeys`
FOR EACH ROW
BEGIN
INSERT INTO `ApiKeysHistory` (
`Id`, `Identifier`, `Key`, `CreatorId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Identifier, OLD.Key, OLD.CreatorId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_ApiKeysDelete`;
CREATE TRIGGER `TR_ApiKeysDelete`
AFTER DELETE
ON `ApiKeys`
FOR EACH ROW
BEGIN
INSERT INTO `ApiKeysHistory` (
`Id`, `Identifier`, `Key`, `CreatorId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Identifier, OLD.Key, OLD.CreatorId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `AuthUserUsersRelations`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AuthUserUsersRelations`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AuthUserUsersRelationsHistory`
(
`Id` BIGINT(20) NOT NULL,
`AuthUserId` BIGINT(20) DEFAULT NULL,
`UserId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_AuthUserUsersRelationsUpdate`;
CREATE TRIGGER `TR_AuthUserUsersRelationsUpdate`
AFTER UPDATE
ON `AuthUserUsersRelations`
FOR EACH ROW
BEGIN
INSERT INTO `AuthUserUsersRelationsHistory` (
`Id`, `AuthUserId`, `UserId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.AuthUserId, OLD.UserId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_AuthUserUsersRelationsDelete`;
CREATE TRIGGER `TR_AuthUserUsersRelationsDelete`
AFTER DELETE
ON `AuthUserUsersRelations`
FOR EACH ROW
BEGIN
INSERT INTO `AuthUserUsersRelationsHistory` (
`Id`, `AuthUserId`, `UserId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.AuthUserId, OLD.UserId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,62 @@
ALTER TABLE `AuthUsers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AuthUsers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AuthUsersHistory`
(
`Id` BIGINT(20) NOT NULL,
`FirstName` VARCHAR(255) DEFAULT NULL,
`LastName` VARCHAR(255) DEFAULT NULL,
`EMail` VARCHAR(255) DEFAULT NULL,
`Password` VARCHAR(255) DEFAULT NULL,
`PasswordSalt` VARCHAR(255) DEFAULT NULL,
`RefreshToken` VARCHAR(255) DEFAULT NULL,
`ConfirmationId` VARCHAR(255) DEFAULT NULL,
`ForgotPasswordId` VARCHAR(255) DEFAULT NULL,
`OAuthId` VARCHAR(255) DEFAULT NULL,
`RefreshTokenExpiryTime` DATETIME(6) NOT NULL,
`AuthRole` BIGINT(11) NOT NULL DEFAULT 0,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_AuthUsersUpdate`;
CREATE TRIGGER `TR_AuthUsersUpdate`
AFTER UPDATE
ON `AuthUsers`
FOR EACH ROW
BEGIN
INSERT INTO `AuthUsersHistory` (
`Id`, `FirstName`, `LastName`, `EMail`, `Password`, `PasswordSalt`,
`RefreshToken`, `ConfirmationId`, `ForgotPasswordId`, `OAuthId`,
`RefreshTokenExpiryTime`, `AuthRole`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.FirstName, OLD.LastName, OLD.EMail, OLD.Password, OLD.PasswordSalt, OLD.RefreshToken,
OLD.ConfirmationId, OLD.ForgotPasswordId, OLD.OAuthId, OLD.RefreshTokenExpiryTime, OLD.AuthRole,
OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_AuthUsersDelete`;
CREATE TRIGGER `TR_AuthUsersDelete`
AFTER DELETE
ON `AuthUsers`
FOR EACH ROW
BEGIN
INSERT INTO `AuthUsersHistory` (
`Id`, `FirstName`, `LastName`, `EMail`, `Password`, `PasswordSalt`, `RefreshToken`,
`ConfirmationId`, `ForgotPasswordId`, `OAuthId`, `RefreshTokenExpiryTime`,
`AuthRole`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.FirstName, OLD.LastName, OLD.EMail, OLD.Password, OLD.PasswordSalt, OLD.RefreshToken,
OLD.ConfirmationId, OLD.ForgotPasswordId, OLD.OAuthId, OLD.RefreshTokenExpiryTime, OLD.AuthRole, TRUE,
OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `AutoRoleRules`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AutoRoleRules`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AutoRoleRulesHistory`
(
`Id` BIGINT(20) NOT NULL,
`AutoRoleId` BIGINT(20) DEFAULT NULL,
`DiscordEmojiName` VARCHAR(64) DEFAULT NULL,
`DiscordRoleId` BIGINT(20) NOT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_AutoRoleRulesUpdate`;
CREATE TRIGGER `TR_AutoRoleRulesUpdate`
AFTER UPDATE
ON `AutoRoleRules`
FOR EACH ROW
BEGIN
INSERT INTO `AutoRoleRulesHistory` (
`Id`, `AutoRoleId`, `DiscordEmojiName`, `DiscordRoleId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.AutoRoleRuleId, OLD.AutoRoleId, OLD.DiscordEmojiName, OLD.DiscordRoleId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_AutoRoleRulesDelete`;
CREATE TRIGGER `TR_AutoRoleRulesDelete`
AFTER DELETE
ON `AutoRoleRules`
FOR EACH ROW
BEGIN
INSERT INTO `AutoRoleRulesHistory` (
`Id`, `AutoRoleId`, `DiscordEmojiName`, `DiscordRoleId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.AutoRoleRuleId, OLD.AutoRoleId, OLD.DiscordEmojiName, OLD.DiscordRoleId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,48 @@
ALTER TABLE `AutoRoles`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AutoRoles`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AutoRolesHistory`
(
`Id` BIGINT(20) NOT NULL,
`ServerId` BIGINT(20) DEFAULT NULL,
`DiscordChannelId` BIGINT(20) NOT NULL,
`DiscordMessageId` BIGINT(20) NOT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_AutoRolesUpdate`;
CREATE TRIGGER `TR_AutoRolesUpdate`
AFTER UPDATE
ON `AutoRoles`
FOR EACH ROW
BEGIN
INSERT INTO `AutoRolesHistory` (
`Id`, `ServerId`, `DiscordChannelId`, `DiscordMessageId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.AutoRoleId, OLD.ServerId, OLD.DiscordChannelId, OLD.DiscordMessageId, OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_AutoRolesDelete`;
CREATE TRIGGER `TR_AutoRolesDelete`
AFTER DELETE
ON `AutoRoles`
FOR EACH ROW
BEGIN
INSERT INTO `AutoRolesHistory` (
`Id`, `ServerId`, `DiscordChannelId`, `DiscordMessageId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.AutoRoleId, OLD.ServerId, OLD.DiscordChannelId, OLD.DiscordMessageId, TRUE, OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,54 @@
ALTER TABLE `Clients`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Clients`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `ClientsHistory`
(
`Id` BIGINT(20) NOT NULL,
`DiscordId` BIGINT(20) NOT NULL,
`SentMessageCount` BIGINT(20) NOT NULL DEFAULT 0,
`ReceivedMessageCount` BIGINT(20) NOT NULL DEFAULT 0,
`DeletedMessageCount` BIGINT(20) NOT NULL DEFAULT 0,
`ReceivedCommandsCount` BIGINT(20) NOT NULL DEFAULT 0,
`MovedUsersCount` BIGINT(20) NOT NULL DEFAULT 0,
`ServerId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_ClientsUpdate`;
CREATE TRIGGER `TR_ClientsUpdate`
AFTER UPDATE
ON `Clients`
FOR EACH ROW
BEGIN
INSERT INTO `ClientsHistory` (
`Id`, `DiscordId`, `SentMessageCount`, `ReceivedMessageCount`, `DeletedMessageCount`,
`ReceivedCommandsCount`, `MovedUsersCount`, `ServerId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.ClientId, OLD.DiscordClientId, OLD.SentMessageCount, OLD.ReceivedMessageCount, OLD.DeletedMessageCount,
OLD.ReceivedCommandsCount, OLD.MovedUsersCount, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_ClientsDelete`;
CREATE TRIGGER `TR_ClientsDelete`
AFTER DELETE
ON `Clients`
FOR EACH ROW
BEGIN
INSERT INTO `ClientsHistory` (
`Id`, `DiscordId`, `SentMessageCount`, `ReceivedMessageCount`, `DeletedMessageCount`,
`ReceivedCommandsCount`, `MovedUsersCount`, `ServerId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.ClientId, OLD.DiscordClientId, OLD.SentMessageCount, OLD.ReceivedMessageCount, OLD.DeletedMessageCount,
OLD.ReceivedCommandsCount, OLD.MovedUsersCount, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `GameServers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `GameServers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `GameServersHistory`
(
`Id` BIGINT(20) NOT NULL,
`Name` VARCHAR(255) NOT NULL,
`ServerId` BIGINT(20) NOT NULL,
`ApiKeyId` BIGINT(20) NOT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_GameServersUpdate`;
CREATE TRIGGER `TR_GameServersUpdate`
AFTER UPDATE
ON `GameServers`
FOR EACH ROW
BEGIN
INSERT INTO `GameServersHistory` (
`Id`, `Name`, `ServerId`, `ApiKeyId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Name, OLD.ServerId, OLD.ApiKeyId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_GameServersDelete`;
CREATE TRIGGER `TR_GameServersDelete`
AFTER DELETE
ON `GameServers`
FOR EACH ROW
BEGIN
INSERT INTO `GameServersHistory` (
`Id`, `Name`, `ServerId`, `ApiKeyId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Name, OLD.ServerId, OLD.ApiKeyId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,44 @@
ALTER TABLE `KnownUsers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `KnownUsers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `KnownUsersHistory`
(
`Id` BIGINT(20) NOT NULL,
`DiscordId` BIGINT(20) NOT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_KnownUsersUpdate`;
CREATE TRIGGER `TR_KnownUsersUpdate`
AFTER UPDATE
ON `KnownUsers`
FOR EACH ROW
BEGIN
INSERT INTO `KnownUsersHistory` (
`Id`, `DiscordId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.KnownUserId, OLD.DiscordId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_KnownUsersDelete`;
CREATE TRIGGER `TR_KnownUsersDelete`
AFTER DELETE
ON `KnownUsers`
FOR EACH ROW
BEGIN
INSERT INTO `KnownUsersHistory` (
`Id`, `DiscordId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.KnownUserId, OLD.DiscordId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,50 @@
ALTER TABLE `Levels`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Levels`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `LevelsHistory`
(
`Id` BIGINT(20) NOT NULL,
`Name` VARCHAR(255) NOT NULL,
`Color` VARCHAR(8) NOT NULL,
`MinXp` BIGINT(20) NOT NULL,
`PermissionInt` BIGINT(20) NOT NULL,
`ServerId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_LevelsUpdate`;
CREATE TRIGGER `TR_LevelsUpdate`
AFTER UPDATE
ON `Levels`
FOR EACH ROW
BEGIN
INSERT INTO `LevelsHistory` (
`Id`, `Name`, `Color`, `MinXp`, `PermissionInt`, `ServerId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Name, OLD.Color, OLD.MinXp, OLD.PermissionInt, OLD.ServerId, OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_LevelsDelete`;
CREATE TRIGGER `TR_LevelsDelete`
AFTER DELETE
ON `Levels`
FOR EACH ROW
BEGIN
INSERT INTO `LevelsHistory` (
`Id`, `Name`, `Color`, `MinXp`, `PermissionInt`, `ServerId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Name, OLD.Color, OLD.MinXp, OLD.PermissionInt, OLD.ServerId, TRUE, OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,44 @@
ALTER TABLE `Servers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Servers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `ServersHistory`
(
`Id` BIGINT(20) NOT NULL,
`DiscordId` BIGINT(20) NOT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_ServersUpdate`;
CREATE TRIGGER `TR_ServersUpdate`
AFTER UPDATE
ON `Servers`
FOR EACH ROW
BEGIN
INSERT INTO `ServersHistory` (
`Id`, `DiscordId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.ServerId, OLD.DiscordServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_ServersDelete`;
CREATE TRIGGER `TR_ServersDelete`
AFTER DELETE
ON `Servers`
FOR EACH ROW
BEGIN
INSERT INTO `ServersHistory` (
`Id`, `DiscordId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.ServerId, OLD.DiscordServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `UserGameIdents`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserGameIdents`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserGameIdentsHistory`
(
`Id` BIGINT(20) NOT NULL,
`UserId` BIGINT(20) NOT NULL,
`GameServerId` BIGINT(20) NOT NULL,
`Ident` VARCHAR(255) NOT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UserGameIdentsUpdate`;
CREATE TRIGGER `TR_UserGameIdentsUpdate`
AFTER UPDATE
ON `UserGameIdents`
FOR EACH ROW
BEGIN
INSERT INTO `UserGameIdentsHistory` (
`Id`, `UserId`, `GameServerId`, `Ident`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.UserId, OLD.GameServerId, OLD.Ident, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UserGameIdentsDelete`;
CREATE TRIGGER `TR_UserGameIdentsDelete`
AFTER DELETE
ON `UserGameIdents`
FOR EACH ROW
BEGIN
INSERT INTO `UserGameIdentsHistory` (
`Id`, `UserId`, `GameServerId`, `Ident`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.UserId, OLD.GameServerId, OLD.Ident, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,47 @@
ALTER TABLE `UserJoinedGameServer`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedGameServer`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserJoinedGameServerHistory`
(
`Id` BIGINT(20) NOT NULL,
`UserId` BIGINT(20) NOT NULL,
`GameServerId` BIGINT(20) NOT NULL,
`JoinedOn` DATETIME(6) NOT NULL,
`LeavedOn` DATETIME(6) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UserJoinedGameServerUpdate`;
CREATE TRIGGER `TR_UserJoinedGameServerUpdate`
AFTER UPDATE
ON `UserJoinedGameServer`
FOR EACH ROW
BEGIN
INSERT INTO `UserJoinedGameServerHistory` (
`Id`, `UserId`, `GameServerId`, `JoinedOn`, `LeavedOn`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.UserId, OLD.GameServerId, OLD.JoinedOn, OLD.LeavedOn, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UserJoinedGameServerDelete`;
CREATE TRIGGER `TR_UserJoinedGameServerDelete`
AFTER DELETE
ON `UserJoinedGameServer`
FOR EACH ROW
BEGIN
INSERT INTO `UserJoinedGameServerHistory` (
`Id`, `UserId`, `GameServerId`, `JoinedOn`, `LeavedOn`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.UserId, OLD.GameServerId, OLD.JoinedOn, OLD.LeavedOn, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `UserJoinedServers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedServers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserJoinedServersHistory`
(
`Id` BIGINT(20) NOT NULL,
`UserId` BIGINT(20) NOT NULL,
`JoinedOn` DATETIME(6) NOT NULL,
`LeavedOn` DATETIME(6) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UserJoinedServersUpdate`;
CREATE TRIGGER `TR_UserJoinedServersUpdate`
AFTER UPDATE
ON `UserJoinedServers`
FOR EACH ROW
BEGIN
INSERT INTO `UserJoinedServersHistory` (
`Id`, `UserId`, `JoinedOn`, `LeavedOn`, `DateFrom`, `DateTo`
)
VALUES (
OLD.JoinId, OLD.UserId, OLD.JoinedOn, OLD.LeavedOn, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UserJoinedServersDelete`;
CREATE TRIGGER `TR_UserJoinedServersDelete`
AFTER DELETE
ON `UserJoinedServers`
FOR EACH ROW
BEGIN
INSERT INTO `UserJoinedServersHistory` (
`Id`, `UserId`, `JoinedOn`, `LeavedOn`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.JoinId, OLD.UserId, OLD.JoinedOn, OLD.LeavedOn, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,49 @@
ALTER TABLE `UserJoinedVoiceChannel`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedVoiceChannel`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserJoinedVoiceChannelHistory`
(
`Id` BIGINT(20) NOT NULL,
`UserId` BIGINT(20) NOT NULL,
`DiscordChannelId` BIGINT(20) NOT NULL,
`JoinedOn` DATETIME(6) NOT NULL,
`LeavedOn` DATETIME(6) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UserJoinedVoiceChannelUpdate`;
CREATE TRIGGER `TR_UserJoinedVoiceChannelUpdate`
AFTER UPDATE
ON `UserJoinedVoiceChannel`
FOR EACH ROW
BEGIN
INSERT INTO `UserJoinedVoiceChannelHistory` (
`Id`, `UserId`, `DiscordChannelId`, `JoinedOn`, `LeavedOn`, `DateFrom`, `DateTo`
)
VALUES (
OLD.JoinId, OLD.UserId, OLD.DiscordChannelId, OLD.JoinedOn, OLD.LeavedOn, OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UserJoinedVoiceChannelDelete`;
CREATE TRIGGER `TR_UserJoinedVoiceChannelDelete`
AFTER DELETE
ON `UserJoinedVoiceChannel`
FOR EACH ROW
BEGIN
INSERT INTO `UserJoinedVoiceChannelHistory` (
`Id`, `UserId`, `DiscordChannelId`, `JoinedOn`, `LeavedOn`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.JoinId, OLD.UserId, OLD.DiscordChannelId, OLD.JoinedOn, OLD.LeavedOn, TRUE, OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,47 @@
ALTER TABLE `UserMessageCountPerHour`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserMessageCountPerHour`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserMessageCountPerHourHistory`
(
`Id` BIGINT(20) NOT NULL,
`Date` DATETIME(6) NOT NULL,
`Hour` BIGINT(20) DEFAULT NULL,
`XPCount` BIGINT(20) DEFAULT NULL,
`UserId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UserMessageCountPerHourUpdate`;
CREATE TRIGGER `TR_UserMessageCountPerHourUpdate`
AFTER UPDATE
ON `UserMessageCountPerHour`
FOR EACH ROW
BEGIN
INSERT INTO `UserMessageCountPerHourHistory` (
`Id`, `UserId`, `Date`, `Hour`, `XPCount`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.UserId, OLD.Date, OLD.Hour, OLD.XPCount, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UserMessageCountPerHourDelete`;
CREATE TRIGGER `TR_UserMessageCountPerHourDelete`
AFTER DELETE
ON `UserMessageCountPerHour`
FOR EACH ROW
BEGIN
INSERT INTO `UserMessageCountPerHourHistory` (
`Id`, `UserId`, `Date`, `Hour`, `XPCount`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.UserId, OLD.Date, OLD.Hour, OLD.XPCount, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `UserWarnings`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserWarnings`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserWarningsHistory`
(
`Id` BIGINT(20) NOT NULL,
`Description` VARCHAR(255) NOT NULL,
`UserId` BIGINT(20) NOT NULL,
`Author` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UserWarningsUpdate`;
CREATE TRIGGER `TR_UserWarningsUpdate`
AFTER UPDATE
ON `UserWarnings`
FOR EACH ROW
BEGIN
INSERT INTO `UserWarningsHistory` (
`Id`, `Description`, `UserId`, `Author`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Description, OLD.UserId, OLD.Author, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UserWarningsDelete`;
CREATE TRIGGER `TR_UserWarningsDelete`
AFTER DELETE
ON `UserWarnings`
FOR EACH ROW
BEGIN
INSERT INTO `UserWarningsHistory` (
`Id`, `Description`, `UserId`, `Author`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.Id, OLD.Description, OLD.UserId, OLD.Author, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,46 @@
ALTER TABLE `Users`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Users`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UsersHistory`
(
`Id` BIGINT(20) NOT NULL,
`DiscordId` BIGINT(20) NOT NULL,
`XP` BIGINT(20) NOT NULL DEFAULT 0,
`ServerId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL
);
DROP TRIGGER IF EXISTS `TR_UsersUpdate`;
CREATE TRIGGER `TR_UsersUpdate`
AFTER UPDATE
ON `Users`
FOR EACH ROW
BEGIN
INSERT INTO `UsersHistory` (
`Id`, `DiscordId`, `XP`, `ServerId`, `DateFrom`, `DateTo`
)
VALUES (
OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;
DROP TRIGGER IF EXISTS `TR_UsersDelete`;
CREATE TRIGGER `TR_UsersDelete`
AFTER DELETE
ON `Users`
FOR EACH ROW
BEGIN
INSERT INTO `UsersHistory` (
`Id`, `DiscordId`, `XP`, `ServerId`, `Deleted`, `DateFrom`, `DateTo`
)
VALUES (
OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)
);
END;

View File

@ -0,0 +1,43 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class RemoveStatsMigration(MigrationABC):
name = "1.0.0_RemoveStatsMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._cursor.execute(
str(
f"""
DROP TABLE IF EXISTS `Statistics`;
"""
)
)
def downgrade(self):
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `Statistics` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Description` VARCHAR(255) NOT NULL,
`Code` LONGTEXT NOT NULL,
`ServerId` BIGINT,
`CreatedAt` DATETIME(6),
`LastModifiedAt` DATETIME(6),
PRIMARY KEY(`Id`),
FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`)
);
"""
)
)

View File

@ -0,0 +1,77 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class UserJoinedGameServerMigration(MigrationABC):
name = "1.0.0_UserJoinedGameServerMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `GameServers` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`ServerId` BIGINT NOT NULL,
`ApiKeyId` BIGINT NOT NULL,
`CreatedAt` DATETIME(6),
`LastModifiedAt` DATETIME(6),
FOREIGN KEY (`ServerId`) REFERENCES Servers(`ServerId`),
FOREIGN KEY (`ApiKeyId`) REFERENCES ApiKeys(`Id`),
PRIMARY KEY(`Id`)
);
"""
)
)
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `UserJoinedGameServer` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`UserId` BIGINT NOT NULL,
`GameServerId` BIGINT NOT NULL,
`JoinedOn` DATETIME(6) NOT NULL,
`LeavedOn` DATETIME(6),
`CreatedAt` DATETIME(6),
`LastModifiedAt` DATETIME(6),
FOREIGN KEY (`UserId`) REFERENCES Users(`UserId`),
FOREIGN KEY (`GameServerId`) REFERENCES GameServers(`Id`),
PRIMARY KEY(`Id`)
);
"""
)
)
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `UserGameIdents` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`UserId` BIGINT NOT NULL,
`GameServerId` BIGINT NOT NULL,
`Ident` VARCHAR(255) NOT NULL,
`CreatedAt` DATETIME(6),
`LastModifiedAt` DATETIME(6),
FOREIGN KEY (`UserId`) REFERENCES Users(`UserId`),
FOREIGN KEY (`GameServerId`) REFERENCES GameServers(`Id`),
CONSTRAINT UC_UserGameIdent UNIQUE (`GameServerId`,`Ident`),
PRIMARY KEY(`Id`)
);
"""
)
)
def downgrade(self):
self._cursor.execute("DROP TABLE `GameServers`;")
self._cursor.execute("DROP TABLE `UserJoinedGameServer`;")
self._cursor.execute("DROP TABLE `UserGameIdents`;")

View File

@ -0,0 +1,37 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class UserWarningMigration(MigrationABC):
name = "1.0.0_UserWarningMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `UserWarnings` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`Description` VARCHAR(255) NOT NULL,
`UserId` BIGINT NOT NULL,
`Author` BIGINT NULL,
`CreatedAt` DATETIME(6),
`LastModifiedAt` DATETIME(6),
PRIMARY KEY(`Id`),
FOREIGN KEY (`UserId`) REFERENCES `Users`(`UserId`),
FOREIGN KEY (`Author`) REFERENCES `Users`(`UserId`)
);
"""
)
)
def downgrade(self):
self._cursor.execute("DROP TABLE `UserWarnings`;")

View File

@ -15,7 +15,7 @@ __title__ = "bot_data.model"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "0.3.1.post1"
__version__ = "1.0.0"
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="0", minor="3", micro="1.post1")
version_info = VersionInfo(major="1", minor="0", micro="0")

Some files were not shown because too many files have changed in this diff Show More