Compare commits

...

87 Commits

Author SHA1 Message Date
9bed89ed60 Fixed level by server id
All checks were successful
Deploy prod on push / pre-build (push) Successful in 10s
Deploy prod on push / build-bot (push) Successful in 4m19s
Deploy prod on push / build-web (push) Successful in 2m49s
Deploy prod on push / deploy (push) Successful in 30s
2024-10-29 18:38:09 +01:00
35fdeb168f Updated docker compose
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 1m59s
Deploy prod on push / build-web (push) Successful in 1m46s
Deploy prod on push / deploy (push) Successful in 22s
2024-09-06 20:50:03 +02:00
e785bddf2e Guild & Level can be null
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 3m19s
Deploy prod on push / build-web (push) Successful in 1m58s
Deploy prod on push / deploy (push) Successful in 23s
2024-09-06 19:39:50 +02:00
b361a7b685 Fixed docker
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 2m17s
Deploy prod on push / build-web (push) Successful in 1m58s
Deploy prod on push / deploy (push) Successful in 23s
2024-06-08 17:25:15 +02:00
bdd0da38ab Check if guild is None in can user see check
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 7m20s
Deploy prod on push / build-web (push) Successful in 2m36s
Deploy prod on push / deploy (push) Successful in 1m29s
2024-02-25 13:42:09 +01:00
179c8a954b Check if guild is None in can user see check
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 3m38s
Deploy prod on push / build-web (push) Successful in 2m41s
Deploy prod on push / deploy (push) Successful in 26s
2024-02-25 13:25:14 +01:00
248d47c280 Fixed update level permission by db state on level seeding
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m14s
Deploy prod on push / build-web (push) Successful in 1m55s
Deploy prod on push / deploy (push) Successful in 25s
2024-02-12 14:59:36 +01:00
414720f53b Update level permission by db state on level seeding
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 3m15s
Deploy prod on push / build-web (push) Successful in 1m54s
Deploy prod on push / deploy (push) Successful in 24s
2024-02-12 14:19:31 +01:00
bb0ff1c560 Check if guild is None
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m4s
Deploy prod on push / build-web (push) Successful in 1m45s
Deploy prod on push / deploy (push) Successful in 22s
2024-02-09 08:48:49 +01:00
521a063fca Fixed technician check when not on the server /2
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 2m58s
Deploy prod on push / build-web (push) Successful in 1m43s
Deploy prod on push / deploy (push) Successful in 21s
2024-02-09 08:27:58 +01:00
dc5ae365bb Fixed technician check when not on the server
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m5s
Deploy prod on push / build-web (push) Successful in 1m46s
Deploy prod on push / deploy (push) Successful in 21s
2024-02-09 08:07:54 +01:00
3c21b68b0c Check user update username
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy staging on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m12s
Deploy prod on push / build-web (push) Successful in 1m53s
Deploy staging on push / build-bot (push) Successful in 2m1s
Deploy prod on push / deploy (push) Successful in 23s
Deploy staging on push / build-web (push) Successful in 2m1s
Deploy staging on push / deploy (push) Successful in 22s
2024-02-03 19:21:57 +01:00
df316fd53b Merge pull request 'Use db pools' (#470) from staging into master
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 2m3s
Deploy prod on push / build-web (push) Successful in 1m49s
Deploy prod on push / deploy (push) Successful in 23s
Reviewed-on: #470
2024-02-01 20:30:03 +01:00
0a18f26a51 Merge branch 'master' into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 2m4s
Deploy staging on push / build-web (push) Successful in 2m0s
Deploy staging on push / deploy (push) Successful in 22s
2024-02-01 20:29:23 +01:00
995c498e54 Use db pools
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m12s
Deploy staging on push / build-web (push) Successful in 1m55s
Deploy staging on push / deploy (push) Successful in 22s
2024-02-01 20:20:05 +01:00
9353fa749c Merge pull request 'staging' (#469) from staging into master
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 2m12s
Deploy prod on push / build-web (push) Successful in 1m53s
Deploy prod on push / deploy (push) Successful in 21s
Reviewed-on: #469
2024-02-01 18:39:49 +01:00
dd4b9182f3 Set version 1.2.7
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m15s
Deploy staging on push / build-web (push) Successful in 2m10s
Deploy staging on push / deploy (push) Successful in 22s
2024-02-01 18:21:17 +01:00
1fc8d441ad Removed fatal from db error handling & improved web error handling 2024-02-01 18:19:31 +01:00
219fffc344 Fixed user warnings
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m7s
Deploy prod on push / build-web (push) Successful in 1m48s
Deploy prod on push / deploy (push) Successful in 21s
2024-01-26 19:20:49 +01:00
fbdac4f57a Fixed user warnings
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m1s
Deploy prod on push / build-web (push) Successful in 1m47s
Deploy prod on push / deploy (push) Successful in 21s
2024-01-26 17:02:52 +01:00
dfee6b0568 Merge pull request 'staging' (#468) from staging into master
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 1m55s
Deploy prod on push / build-web (push) Successful in 1m44s
Deploy prod on push / deploy (push) Successful in 20s
Reviewed-on: #468
2024-01-26 16:33:29 +01:00
9eb09fa3b2 Fixed configs
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m5s
Deploy staging on push / build-web (push) Successful in 1m49s
Deploy staging on push / deploy (push) Successful in 22s
2024-01-26 15:55:46 +01:00
60d81ce18b Resend confirmation mail
Some checks failed
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Failing after 22s
Deploy staging on push / build-web (push) Failing after 21s
Deploy staging on push / deploy (push) Has been skipped
2024-01-26 15:32:01 +01:00
a24fefd3e2 Fixed test mail & delete auth user 2024-01-26 14:03:47 +01:00
8cd5a0d040 Fixed mail 2024-01-26 12:41:26 +01:00
1b8a67e81b Merge pull request 'staging_1.2.6' (#467) from staging_1.2.6 into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 3s
Deploy staging on push / build-bot (push) Successful in 3m25s
Deploy staging on push / build-web (push) Successful in 2m9s
Deploy staging on push / deploy (push) Successful in 23s
Reviewed-on: #467
2024-01-26 12:18:03 +01:00
8318dfe988 Fixed user avatar url 2024-01-26 12:16:13 +01:00
7185b087c9 Fixed level page 2024-01-26 12:13:53 +01:00
07fc512633 Made levels & Achievements public 2024-01-26 12:11:20 +01:00
ca5db6d397 Fixed achievement can see element 2024-01-26 11:53:51 +01:00
7888783b6a Fixed registration by discord 2024-01-26 11:46:48 +01:00
31c62b4108 Added missing translations 2024-01-26 11:37:36 +01:00
b0990b626c Fixed third user warning 2024-01-26 11:36:42 +01:00
df9c889c7e Fixed add new user warning 2024-01-26 11:32:42 +01:00
4d386759c0 Improved data import 2024-01-26 11:06:01 +01:00
3683f5f3d1 Set correct version 2024-01-25 19:28:56 +01:00
77f759a9ca Added user warnings to WI 2024-01-25 19:27:45 +01:00
f209e45905 Added level icons 2024-01-25 17:11:48 +01:00
a917803eff Updated config 2024-01-25 16:46:03 +01:00
acfa359eeb Fixed loading scheduled events 2024-01-25 16:45:05 +01:00
baf7b8d7de Merge pull request 'Fixed afk command' (#465) from staging into master
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 1m56s
Deploy prod on push / build-web (push) Successful in 1m52s
Deploy prod on push / deploy (push) Successful in 23s
Reviewed-on: #465
2024-01-13 15:17:01 +01:00
ee69ae58d1 Fixed afk command
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m21s
Deploy staging on push / build-web (push) Successful in 1m49s
Deploy staging on push / deploy (push) Successful in 23s
2024-01-13 15:16:39 +01:00
bc528f1474 Merge pull request 'staging' (#464) from staging into master
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 1m57s
Deploy prod on push / build-web (push) Successful in 1m49s
Deploy prod on push / deploy (push) Successful in 22s
Reviewed-on: #464
2024-01-13 15:06:06 +01:00
d67ba924dc Merge branch 'master' into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m6s
Deploy staging on push / build-web (push) Successful in 1m43s
Deploy staging on push / deploy (push) Successful in 24s
2024-01-13 15:00:11 +01:00
e054c04c96 Tried to improve db connection
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m3s
Deploy staging on push / build-web (push) Successful in 1m49s
Deploy staging on push / deploy (push) Successful in 23s
2024-01-13 14:51:31 +01:00
c846614274 Set version 1.2.5 2024-01-13 13:36:47 +01:00
83764b3cee Added logic to remove short role name for all members by deleting
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m3s
Deploy staging on push / build-web (push) Successful in 1m57s
Deploy staging on push / deploy (push) Successful in 25s
2024-01-13 13:04:52 +01:00
4553490266 Add logic to other users to afk as mod 2024-01-11 20:56:19 +01:00
35aa2574f8 Fixed level order
All checks were successful
Deploy prod on push / pre-build (push) Successful in 2s
Deploy prod on push / build-bot (push) Successful in 3m17s
Deploy prod on push / build-web (push) Successful in 2m2s
Deploy prod on push / deploy (push) Successful in 27s
2023-12-17 11:36:49 +01:00
ccae285b81 Merge pull request 'Removed empty cp' (#463) from staging into master
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m58s
Deploy prod on push / build-web (push) Successful in 2m4s
Deploy prod on push / deploy (push) Successful in 1m1s
Reviewed-on: #463
2023-12-17 01:10:40 +01:00
887a02a7af Removed empty cp
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 4m3s
Deploy staging on push / build-web (push) Successful in 1m47s
Deploy staging on push / deploy (push) Successful in 1m5s
2023-12-17 01:10:07 +01:00
f484c553b3 Merge pull request 'staging' (#462) from staging into master
Some checks failed
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 4m4s
Deploy prod on push / build-web (push) Failing after 58s
Deploy prod on push / deploy (push) Has been skipped
Reviewed-on: #462
2023-12-17 01:03:13 +01:00
c5eca69db1 Merge pull request '#460' (#461) from #460 into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m17s
Deploy staging on push / build-web (push) Successful in 1m54s
Deploy staging on push / deploy (push) Successful in 25s
Reviewed-on: #461
2023-12-15 15:40:12 +01:00
d1a04c537c Set correct frontend version #460 2023-12-15 15:39:14 +01:00
72715aac62 Added frontend implementation #460 2023-12-15 15:38:38 +01:00
e516def7ef Added reset member after rejoin setting to gql #460 2023-12-15 15:20:39 +01:00
f1f5954dfc Added reset member after rejoin setting to backend [untested] #460 2023-12-15 13:42:49 +01:00
266dacb301 Fixed deps
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m12s
Deploy staging on push / build-web (push) Successful in 2m1s
Deploy staging on push / deploy (push) Successful in 26s
Deploy dev on push / pre-build (push) Successful in 2s
Deploy dev on push / build-bot (push) Successful in 1m55s
Deploy dev on push / build-web (push) Successful in 1m46s
Deploy dev on push / deploy (push) Successful in 23s
2023-12-13 12:11:09 +01:00
280cd9827d shutdown correct stack
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 2m1s
Deploy staging on push / build-web (push) Successful in 1m57s
Deploy staging on push / deploy (push) Successful in 22s
2023-12-13 11:59:21 +01:00
36998470e8 Try filtering scheduled events
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m0s
Deploy staging on push / build-web (push) Successful in 2m7s
Deploy staging on push / deploy (push) Successful in 24s
2023-12-13 11:25:51 +01:00
53c6bf4208 Merge pull request 'Added gmod support #277' (#459) from #277 into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m8s
Deploy staging on push / build-web (push) Successful in 1m47s
Deploy staging on push / deploy (push) Successful in 24s
Reviewed-on: #459
2023-12-12 11:49:43 +01:00
4e80e3ccb7 Added gmod support #277 2023-12-11 21:34:38 +01:00
ba173a6743 Improved xp knob #409
All checks were successful
Deploy staging on push / pre-build (push) Successful in 2s
Deploy staging on push / build-bot (push) Successful in 3m4s
Deploy staging on push / build-web (push) Successful in 1m56s
Deploy staging on push / deploy (push) Successful in 26s
2023-12-10 19:50:44 +01:00
84ff2a8a9b Fixed update user #455 2023-12-10 19:18:20 +01:00
13bc38fea8 Updated profile #409 2023-12-10 19:00:00 +01:00
dfdf0555d7 Added feature flag check for scheduled events #455
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m6s
Deploy staging on push / build-web (push) Successful in 1m57s
Deploy staging on push / deploy (push) Successful in 28s
2023-12-10 17:08:26 +01:00
39299eb11b Made watchers transient
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 3m46s
Deploy staging on push / build-web (push) Successful in 2m5s
Deploy staging on push / deploy (push) Successful in 28s
2023-12-10 13:13:24 +01:00
dfb6751bf9 Set event watcher loop from 12 to 3 hours
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 2m52s
Deploy staging on push / build-web (push) Successful in 1m53s
Deploy staging on push / deploy (push) Successful in 32s
2023-12-10 11:18:30 +01:00
4a75635a55 Fixed actions
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 1m47s
Deploy staging on push / build-web (push) Successful in 1m42s
Deploy staging on push / deploy (push) Successful in 22s
2023-12-09 22:48:37 +01:00
f6b2739394 Merge pull request 'Fixed actions' (#458) from dev into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 1m52s
Deploy staging on push / build-web (push) Successful in 1m44s
Deploy staging on push / deploy (push) Successful in 23s
Reviewed-on: #458
2023-12-09 22:38:35 +01:00
36d2605655 Merge branch 'staging' into dev
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 1m53s
Deploy dev on push / build-web (push) Successful in 1m47s
Deploy dev on push / deploy (push) Successful in 21s
2023-12-09 22:38:16 +01:00
af891fa588 Fixed actions
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 1m51s
Deploy dev on push / build-web (push) Successful in 1m50s
Deploy dev on push / deploy (push) Successful in 23s
2023-12-09 22:33:14 +01:00
af348b85a4 Merge pull request 'dev into staging' (#457) from dev into staging
All checks were successful
Deploy staging on push / pre-build (push) Successful in 1s
Deploy staging on push / build-bot (push) Successful in 1m46s
Deploy staging on push / build-web (push) Successful in 1m44s
Deploy staging on push / deploy (push) Successful in 27s
Reviewed-on: #457
2023-12-09 22:23:06 +01:00
7ed621a25b Fixed actions
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 1m52s
Deploy dev on push / build-web (push) Successful in 1m41s
Deploy dev on push / deploy (push) Successful in 21s
2023-12-09 22:17:56 +01:00
013f953a7f Fixed actions
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 1m53s
Deploy dev on push / build-web (push) Successful in 1m42s
Deploy dev on push / deploy (push) Successful in 23s
2023-12-09 22:10:04 +01:00
4163532696 Fixed actions
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 1m52s
Deploy dev on push / build-web (push) Successful in 1m57s
Deploy dev on push / deploy (push) Successful in 6s
2023-12-09 22:02:57 +01:00
b6a1172cc1 Fixed actions
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 2m0s
Deploy dev on push / build-web (push) Successful in 1m47s
Deploy dev on push / deploy (push) Successful in 6s
2023-12-09 21:51:47 +01:00
20bdb6bd98 Updated compose files
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 2m1s
Deploy dev on push / build-web (push) Successful in 1m42s
Deploy dev on push / deploy (push) Successful in 5s
2023-12-09 21:46:01 +01:00
3f13f65932 Updated other env actions 2023-12-09 21:43:34 +01:00
711e184895 Fixed dev action
All checks were successful
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 1m48s
Deploy dev on push / build-web (push) Successful in 1m53s
Deploy dev on push / deploy (push) Successful in 5s
2023-12-09 21:34:21 +01:00
7e3975f4be Fixed dev action
Some checks failed
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Successful in 2m13s
Deploy dev on push / build-web (push) Successful in 1m43s
Deploy dev on push / deploy (push) Failing after 1s
2023-12-09 21:28:15 +01:00
d4f4f39522 Fixed dev action
Some checks failed
Deploy dev on push / pre-build (push) Successful in 1s
Deploy dev on push / build-bot (push) Failing after 1m55s
Deploy dev on push / build-web (push) Failing after 1m45s
Deploy dev on push / deploy (push) Has been skipped
2023-12-09 21:22:00 +01:00
af9c55e4b1 Updated dev action
Some checks failed
Deploy dev on push / pre-build (push) Successful in 2s
Deploy dev on push / build-bot (push) Failing after 2m3s
Deploy dev on push / build-web (push) Failing after 2m5s
Deploy dev on push / deploy (push) Has been skipped
2023-12-09 21:00:20 +01:00
e3172d6f24 Fixed event logger
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m22s
2023-12-09 14:11:34 +01:00
0706579f62 Fixed set timestamp for scheduled events #456
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m9s
2023-12-09 14:05:35 +01:00
ad3fc94923 Improved logging for event_service
All checks were successful
Deploy staging on push / on-push-deploy_sh-edraft (push) Successful in 4m13s
2023-12-09 13:58:38 +01:00
69882af0bd Added event logger
Some checks reported warnings
Deploy staging on push / on-push-deploy_sh-edraft (push) Has been cancelled
2023-12-09 13:55:40 +01:00
221 changed files with 2596 additions and 1028 deletions

View File

@ -6,9 +6,17 @@ on:
- dev - dev
jobs: jobs:
on-push-deploy_sh-edraft: pre-build:
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ] runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: sh-edraft.de/act-runner:latest container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Shutdown stack
run: docker stack rm sdb_dev
build-bot:
needs: pre-build
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps: steps:
- name: Setup docker - name: Setup docker
uses: https://github.com/papodaca/install-docker-action@main uses: https://github.com/papodaca/install-docker-action@main
@ -22,10 +30,44 @@ jobs:
- name: Prepare bot build - name: Prepare bot build
run: | run: |
cd bot
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
cd bot
cpl i cpl i
- name: Build docker bot
run: |
cd bot
docker image prune -f
cpl build
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-dev .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
cd bot
docker push git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-dev
build-web:
needs: pre-build
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Setup docker
uses: https://github.com/papodaca/install-docker-action@main
- run: docker -v
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Setup node - name: Setup node
uses: https://github.com/actions/setup-node@v3 uses: https://github.com/actions/setup-node@v3
@ -35,29 +77,45 @@ jobs:
npm install -g ts-node npm install -g ts-node
npm ci npm ci
- name: Shutdown stack
run: docker stack rm sdb_dev
- name: Build docker bot
run: |
cd bot
docker image prune -f
cpl build
docker build -t sh-edraft.de/sdb-bot:$(cpl gv)-dev .
- name: Build docker web - name: Build docker web
run: | run: |
cd web cd web
docker image prune -f docker image prune -f
cp src/favicon.dev.ico src/favicon.ico cp src/favicon.dev.ico src/favicon.ico
npm run build npm run build
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv)-dev . docker build -t git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-dev .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
cd web
docker push git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-dev
deploy:
needs: [ build-bot, build-web ]
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Install cpl
run: python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
- name: Set version - name: Set version
run: | run: |
cd bot/docker cd bot/docker
chmod +x ./set-docker-compose-image-version.sh chmod +x ./set-docker-compose-image-version.sh
./set-docker-compose-image-version.sh sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-dev sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-dev ./set-docker-compose-image-version.sh git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-dev git.sh-edraft.de/sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-dev
- name: Deploy Stack to sh-edraft.de - name: Deploy Stack to sh-edraft.de
uses: https://github.com/kgierke/portainer-stack-deployment@v1 uses: https://github.com/kgierke/portainer-stack-deployment@v1

View File

@ -6,9 +6,17 @@ on:
- master - master
jobs: jobs:
on-push-deploy_sh-edraft: pre-build:
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ] runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: sh-edraft.de/act-runner:latest container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Shutdown stack
run: docker stack rm sdb_prod
build-bot:
needs: pre-build
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps: steps:
- name: Setup docker - name: Setup docker
uses: https://github.com/papodaca/install-docker-action@main uses: https://github.com/papodaca/install-docker-action@main
@ -22,10 +30,44 @@ jobs:
- name: Prepare bot build - name: Prepare bot build
run: | run: |
cd bot
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
cd bot
cpl i cpl i
- name: Build docker bot
run: |
cd bot
docker image prune -f
cpl build
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv) .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
cd bot
docker push git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)
build-web:
needs: pre-build
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Setup docker
uses: https://github.com/papodaca/install-docker-action@main
- run: docker -v
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Setup node - name: Setup node
uses: https://github.com/actions/setup-node@v3 uses: https://github.com/actions/setup-node@v3
@ -35,28 +77,44 @@ jobs:
npm install -g ts-node npm install -g ts-node
npm ci npm ci
- name: Shutdown stack
run: docker stack rm sdb_prod
- name: Build docker bot
run: |
cd bot
docker image prune -f
cpl build
docker build -t sh-edraft.de/sdb-bot:$(cpl gv) .
- name: Build docker web - name: Build docker web
run: | run: |
cd web cd web
docker image prune -f docker image prune -f
npm run build npm run build
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv) . docker build -t git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv) .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
cd web
docker push git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)
deploy:
needs: [ build-bot, build-web ]
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Install cpl
run: python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
- name: Set version - name: Set version
run: | run: |
cd bot/docker cd bot/docker
chmod +x ./set-docker-compose-image-version.sh chmod +x ./set-docker-compose-image-version.sh
./set-docker-compose-image-version.sh sh-edraft.de/sdb-bot:$(cd ../; cpl gv) sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;) ./set-docker-compose-image-version.sh git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cd ../; cpl gv) git.sh-edraft.de/sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)
- name: Deploy Stack to sh-edraft.de - name: Deploy Stack to sh-edraft.de
uses: https://github.com/kgierke/portainer-stack-deployment@v1 uses: https://github.com/kgierke/portainer-stack-deployment@v1

View File

@ -6,9 +6,17 @@ on:
- staging - staging
jobs: jobs:
on-push-deploy_sh-edraft: pre-build:
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ] runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: sh-edraft.de/act-runner:latest container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Shutdown stack
run: docker stack rm sdb_staging
build-bot:
needs: pre-build
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps: steps:
- name: Setup docker - name: Setup docker
uses: https://github.com/papodaca/install-docker-action@main uses: https://github.com/papodaca/install-docker-action@main
@ -22,10 +30,44 @@ jobs:
- name: Prepare bot build - name: Prepare bot build
run: | run: |
cd bot
python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
cd bot
cpl i cpl i
- name: Build docker bot
run: |
cd bot
docker image prune -f
cpl build
docker build -t git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-staging .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
cd bot
docker push git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cpl gv)-staging
build-web:
needs: pre-build
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Setup docker
uses: https://github.com/papodaca/install-docker-action@main
- run: docker -v
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Setup node - name: Setup node
uses: https://github.com/actions/setup-node@v3 uses: https://github.com/actions/setup-node@v3
@ -35,29 +77,45 @@ jobs:
npm install -g ts-node npm install -g ts-node
npm ci npm ci
- name: Shutdown stack
run: docker stack rm sdb_staging
- name: Build docker bot
run: |
cd bot
docker image prune -f
cpl build
docker build -t sh-edraft.de/sdb-bot:$(cpl gv)-staging .
- name: Build docker web - name: Build docker web
run: | run: |
cd web cd web
docker image prune -f docker image prune -f
cp src/favicon.staging.ico src/favicon.ico cp src/favicon.staging.ico src/favicon.ico
npm run build npm run build
docker build -t sh-edraft.de/sdb-web:$(npm run -s gv)-staging . docker build -t git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-staging .
- name: Login to registry git.sh-edraft.de
uses: https://github.com/docker/login-action@v1
with:
registry: git.sh-edraft.de
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_ACCESS_TOKEN }}
- name: Push image
run: |
cd web
docker push git.sh-edraft.de/sh-edraft.de/sdb-web:$(npm run -s gv)-staging
deploy:
needs: [ build-bot, build-web ]
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
steps:
- name: Clone Repository
uses: https://github.com/actions/checkout@v3
with:
token: ${{ secrets.CI_ACCESS_TOKEN }}
submodules: true
- name: Install cpl
run: python3.10 -m pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
- name: Set version - name: Set version
run: | run: |
cd bot/docker cd bot/docker
chmod +x ./set-docker-compose-image-version.sh chmod +x ./set-docker-compose-image-version.sh
./set-docker-compose-image-version.sh sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-staging sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-staging ./set-docker-compose-image-version.sh git.sh-edraft.de/sh-edraft.de/sdb-bot:$(cd ../; cpl gv)-staging git.sh-edraft.de/sh-edraft.de/sdb-web:$(cd ../../web; npm run -s gv;)-staging
- name: Deploy Stack to sh-edraft.de - name: Deploy Stack to sh-edraft.de
uses: https://github.com/kgierke/portainer-stack-deployment@v1 uses: https://github.com/kgierke/portainer-stack-deployment@v1

@ -1 +1 @@
Subproject commit abd17085309242a2aa0b415a9a14d5390163dfc2 Subproject commit fbcd9226c4d199529fdbce5169b38b1b23074adb

View File

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

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "2", "Minor": "2",
"Micro": "3" "Micro": "8"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",
@ -16,7 +16,6 @@
"LicenseName": "MIT", "LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.", "LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [ "Dependencies": [
"cpl-core==2023.10.1",
"cpl-translation==2023.4.0.post1", "cpl-translation==2023.4.0.post1",
"cpl-query==2023.10.0", "cpl-query==2023.10.0",
"cpl-discord==2023.10.0.post1", "cpl-discord==2023.10.0.post1",
@ -33,7 +32,9 @@
"cryptography==41.0.4", "cryptography==41.0.4",
"discord==2.3.2", "discord==2.3.2",
"bs4==0.0.1", "bs4==0.0.1",
"lxml==4.9.3" "lxml==4.9.3",
"python-valve==0.2.1",
"cpl-core==2023.10.2"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli==2023.4.0.post3", "cpl-cli==2023.4.0.post3",

@ -1 +1 @@
Subproject commit 4669bf7c43c7aec368a1a1917ea92038c007944f Subproject commit eeebd13f80c6ceecc922ede5771e55212a884019

View File

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

View File

@ -15,6 +15,7 @@ from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
from bot_core.logging.command_logger import CommandLogger from bot_core.logging.command_logger import CommandLogger
from bot_core.logging.database_logger import DatabaseLogger from bot_core.logging.database_logger import DatabaseLogger
from bot_core.logging.event_logger import EventLogger
from bot_core.logging.message_logger import MessageLogger from bot_core.logging.message_logger import MessageLogger
from bot_core.logging.task_logger import TaskLogger from bot_core.logging.task_logger import TaskLogger
from bot_data.db_context import DBContext from bot_data.db_context import DBContext
@ -45,6 +46,7 @@ class Startup(StartupABC):
services.add_singleton(CustomFileLoggerABC, DatabaseLogger) services.add_singleton(CustomFileLoggerABC, DatabaseLogger)
services.add_singleton(CustomFileLoggerABC, MessageLogger) services.add_singleton(CustomFileLoggerABC, MessageLogger)
services.add_singleton(CustomFileLoggerABC, TaskLogger) services.add_singleton(CustomFileLoggerABC, TaskLogger)
services.add_singleton(CustomFileLoggerABC, EventLogger)
if self._feature_flags.get_flag(FeatureFlagsEnum.api_module): if self._feature_flags.get_flag(FeatureFlagsEnum.api_module):
services.add_singleton(CustomFileLoggerABC, ApiLogger) services.add_singleton(CustomFileLoggerABC, ApiLogger)

View File

@ -2,22 +2,22 @@
"api": { "api": {
"api": { "api": {
"test_mail": { "test_mail": {
"message": "Dies ist eine Test-Mail vom Krümelmonster Web Interface\nGesendet von {}-{}", "message": "Dies ist eine Test-Mail vom Krümelmonster Web Interface\r\nGesendet von {}-{}",
"subject": "Krümelmonster Web Interface Test-Mail" "subject": "Krümelmonster Web Interface Test-Mail"
} }
}, },
"auth": { "auth": {
"confirmation": { "confirmation": {
"message": "Öffne den Link, um die E-Mail zu bestätigen:\n{}auth/register/{}", "message": "Öffne den Link, um die E-Mail zu bestätigen:\r\n{}auth/register/{}",
"subject": "E-Mail für {} {} bestätigen" "subject": "E-Mail für {} {} bestätigen"
}, },
"forgot_password": { "forgot_password": {
"message": "Öffne den Link, um das Passwort zu ändern:\n{}auth/forgot-password/{}", "message": "Öffne den Link, um das Passwort zu ändern:\r\n{}auth/forgot-password/{}",
"subject": "Passwort für {} {} zurücksetzen" "subject": "Passwort für {} {} zurücksetzen"
} }
}, },
"mail": { "mail": {
"automatic_mail": "\n\nDies ist eine automatische E-Mail.\nGesendet von {}-{}@{}" "automatic_mail": "\r\n\r\nDies ist eine automatische E-Mail.\r\nGesendet von {}-{}@{}"
} }
}, },
"common": { "common": {

View File

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

View File

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

View File

@ -114,3 +114,7 @@ class AuthServiceABC(ABC):
@abstractmethod @abstractmethod
async def reset_password_async(self, rp_dto: ResetPasswordDTO): async def reset_password_async(self, rp_dto: ResetPasswordDTO):
pass pass
@abstractmethod
async def resend_confirmation_email_by_mail(self, mail: str):
pass

View File

@ -16,8 +16,8 @@ from werkzeug.exceptions import NotFound
from bot_api.configuration.api_settings import ApiSettings from bot_api.configuration.api_settings import ApiSettings
from bot_api.configuration.authentication_settings import AuthenticationSettings from bot_api.configuration.authentication_settings import AuthenticationSettings
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException from bot_core.exception.service_exception import ServiceException
from bot_api.logging.api_logger import ApiLogger from bot_api.logging.api_logger import ApiLogger
from bot_api.model.error_dto import ErrorDTO from bot_api.model.error_dto import ErrorDTO
from bot_api.route.route import Route from bot_api.route.route import Route

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "2", "Minor": "2",
"Micro": "3" "Micro": "8"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

@ -1 +1 @@
Subproject commit 521951b8abb0f784b59b6d3e0210606fa193e60a Subproject commit 12ffcbcd9b88612251a1e23cb6724e21562f74b8

View File

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

View File

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

View File

@ -84,13 +84,13 @@ class AuthController:
self._auth_service.add_auth_user(dto) self._auth_service.add_auth_user(dto)
return "", 200 return "", 200
@Route.post(f"{BasePath}/resend-confirmation-email-by-mail/<mail>")
async def resend_confirmation_email_by_user_id(self, mail: str):
await self._auth_service.resend_confirmation_email_by_mail(mail)
return "", 200
@Route.post(f"{BasePath}/register-by-id/<id>") @Route.post(f"{BasePath}/register-by-id/<id>")
async def register_id(self, id: str): async def register_id(self, id: str):
if not FeatureFlagsSettings.get_flag_from_dict(
self._technician_config.feature_flags, FeatureFlagsEnum.basic_registration
):
return
result = await self._auth_service.confirm_email_async(id) result = await self._auth_service.confirm_email_async(id)
return jsonify(result) return jsonify(result)

View File

@ -16,6 +16,7 @@ from bot_api.api import Api
from bot_api.configuration.discord_authentication_settings import ( from bot_api.configuration.discord_authentication_settings import (
DiscordAuthenticationSettings, DiscordAuthenticationSettings,
) )
from bot_core.exception.service_exception import ServiceException
from bot_api.logging.api_logger import ApiLogger from bot_api.logging.api_logger import ApiLogger
from bot_api.model.auth_user_dto import AuthUserDTO from bot_api.model.auth_user_dto import AuthUserDTO
from bot_api.route.route import Route from bot_api.route.route import Route
@ -90,5 +91,10 @@ class AuthDiscordController:
AuthRoleEnum.normal, AuthRoleEnum.normal,
) )
result = await self._auth_service.login_discord_async(dto, response["id"]) try:
return jsonify(result.to_dict()) result = await self._auth_service.login_discord_async(dto, response["id"])
return jsonify(result.to_dict())
except ServiceException as e:
r = jsonify({"email": dto.email})
r.status_code = 403
return r

View File

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

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
"""
bot sh-edraft.de Discord bot
~~~~~~~~~~~~~~~~~~~
Discord bot for customers of sh-edraft.de
:copyright: (c) 2022 - 2023 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = "bot_api.exception"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.2.3"
from collections import namedtuple
# imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="2", micro="3")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,7 @@
import traceback
from typing import Optional from typing import Optional
from cpl_core.console import Console
from bot_api.abc.dto_abc import DtoABC from bot_api.abc.dto_abc import DtoABC
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
class ErrorDTO(DtoABC): class ErrorDTO(DtoABC):

View File

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

View File

@ -8,8 +8,8 @@ from flask import request, jsonify
from flask_cors import cross_origin from flask_cors import cross_origin
from bot_api.abc.auth_service_abc import AuthServiceABC from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException from bot_core.exception.service_exception import ServiceException
from bot_api.model.error_dto import ErrorDTO from bot_api.model.error_dto import ErrorDTO
from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC from bot_data.abc.auth_user_repository_abc import AuthUserRepositoryABC
from bot_data.model.auth_role_enum import AuthRoleEnum from bot_data.model.auth_role_enum import AuthRoleEnum

View File

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

View File

@ -1,6 +1,5 @@
import hashlib import hashlib
import re import re
import textwrap
import uuid import uuid
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from threading import Thread from threading import Thread
@ -19,8 +18,8 @@ from flask import request
from bot_api.abc.auth_service_abc import AuthServiceABC from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.configuration.authentication_settings import AuthenticationSettings from bot_api.configuration.authentication_settings import AuthenticationSettings
from bot_api.configuration.frontend_settings import FrontendSettings from bot_api.configuration.frontend_settings import FrontendSettings
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException from bot_core.exception.service_exception import ServiceException
from bot_api.filter.auth_user_select_criteria import AuthUserSelectCriteria from bot_api.filter.auth_user_select_criteria import AuthUserSelectCriteria
from bot_api.logging.api_logger import ApiLogger from bot_api.logging.api_logger import ApiLogger
from bot_api.model.auth_user_dto import AuthUserDTO from bot_api.model.auth_user_dto import AuthUserDTO
@ -172,11 +171,7 @@ class AuthService(AuthServiceABC):
mail.add_header("Content-Transfer-Encoding: quoted-printable") mail.add_header("Content-Transfer-Encoding: quoted-printable")
mail.add_receiver(str(email)) mail.add_receiver(str(email))
mail.subject = subject mail.subject = subject
mail.body = textwrap.dedent( mail.body = f"{message}\r\n{self._t.transform('api.mail.automatic_mail').format(self._environment.application_name, self._environment.environment_name, self._environment.host_name)}"
f"""{message}
{self._t.transform('api.mail.automatic_mail').format(self._environment.application_name, self._environment.environment_name, self._environment.host_name)}
"""
)
thr = Thread(target=self._mailer.send_mail, args=[mail]) thr = Thread(target=self._mailer.send_mail, args=[mail])
thr.start() thr.start()
@ -599,3 +594,12 @@ class AuthService(AuthServiceABC):
user.forgot_password_id = None user.forgot_password_id = None
self._auth_users.update_auth_user(user) self._auth_users.update_auth_user(user)
self._db.save_changes() self._db.save_changes()
async def resend_confirmation_email_by_mail(self, mail: str):
user = self._auth_users.find_auth_user_by_email(mail)
if user is None:
raise ServiceException(ServiceErrorCode.InvalidUser, f"User not found")
if user.confirmation_id is None:
raise ServiceException(ServiceErrorCode.DataAlreadyExists, f"User already confirmed")
self._send_confirmation_id_to_user(user)

View File

@ -4,8 +4,8 @@ from cpl_discord.service import DiscordBotServiceABC
from cpl_query.extension import List from cpl_query.extension import List
from bot_api.abc.auth_service_abc import AuthServiceABC from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException from bot_core.exception.service_exception import ServiceException
from bot_api.filter.discord.server_select_criteria import ServerSelectCriteria 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_dto import ServerDTO
from bot_api.model.discord.server_filtered_result_dto import ServerFilteredResultDTO from bot_api.model.discord.server_filtered_result_dto import ServerFilteredResultDTO

View File

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

View File

@ -35,21 +35,37 @@ class AuthUserTransformer(TransformerABC):
@ServiceProviderABC.inject @ServiceProviderABC.inject
def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id) guild = bot.get_guild(user.server.discord_id)
if guild is None:
return permissions.is_member_technician_by_id(user.discord_id)
member = guild.get_member(user.discord_id) member = guild.get_member(user.discord_id)
if member is None:
return permissions.is_member_technician_by_id(user.discord_id)
return permissions.is_member_technician(member) return permissions.is_member_technician(member)
@staticmethod @staticmethod
@ServiceProviderABC.inject @ServiceProviderABC.inject
def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id) guild = bot.get_guild(user.server.discord_id)
if guild is None:
return False
member = guild.get_member(user.discord_id) member = guild.get_member(user.discord_id)
if member is None:
return False
return permissions.is_member_admin(member) return permissions.is_member_admin(member)
@staticmethod @staticmethod
@ServiceProviderABC.inject @ServiceProviderABC.inject
def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id) guild = bot.get_guild(user.server.discord_id)
if guild is None:
return False
member = guild.get_member(user.discord_id) member = guild.get_member(user.discord_id)
if member is None:
return False
return permissions.is_member_moderator(member) return permissions.is_member_moderator(member)
@classmethod @classmethod

View File

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

View File

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

View File

@ -19,3 +19,7 @@ class PermissionServiceABC(ABC):
@abstractmethod @abstractmethod
def is_member_technician(self, member: discord.Member) -> bool: def is_member_technician(self, member: discord.Member) -> bool:
pass pass
@abstractmethod
def is_member_technician_by_id(self, member_id: int) -> bool:
pass

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "2", "Minor": "2",
"Micro": "3" "Micro": "8"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

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

View File

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

View File

@ -1,20 +1,18 @@
import asyncio
from cpl_core.configuration import ConfigurationABC from cpl_core.configuration import ConfigurationABC
from cpl_core.logging import LoggerABC
from cpl_discord.events import OnReadyABC from cpl_discord.events import OnReadyABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe from cpl_translation import TranslatePipe
from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_core.abc.client_utils_abc import ClientUtilsABC
from bot_core.environment_variables import MAINTENANCE from bot_core.environment_variables import MAINTENANCE
from bot_core.logging.event_logger import EventLogger
class CoreExtensionOnReadyEvent(OnReadyABC): class CoreExtensionOnReadyEvent(OnReadyABC):
def __init__( def __init__(
self, self,
config: ConfigurationABC, config: ConfigurationABC,
logger: LoggerABC, logger: EventLogger,
bot: DiscordBotServiceABC, bot: DiscordBotServiceABC,
client_utils: ClientUtilsABC, client_utils: ClientUtilsABC,
t: TranslatePipe, t: TranslatePipe,

View File

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

View File

@ -1,15 +1,15 @@
from cpl_core.logging import LoggerABC
from cpl_discord.events import OnReadyABC from cpl_discord.events import OnReadyABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe from cpl_translation import TranslatePipe
from bot_core.abc.client_utils_abc import ClientUtilsABC from bot_core.abc.client_utils_abc import ClientUtilsABC
from bot_core.logging.event_logger import EventLogger
class CoreOnReadyEvent(OnReadyABC): class CoreOnReadyEvent(OnReadyABC):
def __init__( def __init__(
self, self,
logger: LoggerABC, logger: EventLogger,
bot: DiscordBotServiceABC, bot: DiscordBotServiceABC,
client_utils: ClientUtilsABC, client_utils: ClientUtilsABC,
t: TranslatePipe, t: TranslatePipe,

View File

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

View File

@ -1,4 +1,4 @@
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
class ServiceException(Exception): class ServiceException(Exception):

View File

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

View File

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

View File

@ -0,0 +1,15 @@
from cpl_core.configuration import ConfigurationABC
from cpl_core.environment import ApplicationEnvironmentABC
from cpl_core.time import TimeFormatSettings
from bot_core.abc.custom_file_logger_abc import CustomFileLoggerABC
class EventLogger(CustomFileLoggerABC):
def __init__(
self,
config: ConfigurationABC,
time_format: TimeFormatSettings,
env: ApplicationEnvironmentABC,
):
CustomFileLoggerABC.__init__(self, "Event", config, time_format, env)

View File

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

View File

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

View File

@ -5,11 +5,11 @@ from cpl_core.configuration import ConfigurationABC
from cpl_core.logging import LoggerABC from cpl_core.logging import LoggerABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from bot_core.abc.permission_service_abc import PermissionServiceABC
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
from bot_core.abc.permission_service_abc import PermissionServiceABC
class PermissionService(PermissionServiceABC): class PermissionService(PermissionServiceABC):
@ -112,3 +112,18 @@ class PermissionService(PermissionServiceABC):
except Exception as e: except Exception as e:
self._logger.error(__name__, "Permission check failed", e) self._logger.error(__name__, "Permission check failed", e)
return False return False
def is_member_technician_by_id(self, member_id: int):
has_permission_cached = self.get_cached_permission(member_id, TeamMemberTypeEnum.technician)
if has_permission_cached is not None:
return has_permission_cached
self._logger.debug(__name__, f"Checking is member {member_id} technician")
try:
has_permission = member_id in self._technician_configs.get_technician_config().technician_ids
self.set_cached_permission(has_permission, member_id, TeamMemberTypeEnum.technician)
return has_permission
except Exception as e:
self._logger.error(__name__, "Permission check failed", e)
return False

View File

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

View File

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

View File

@ -18,6 +18,10 @@ class UserWarningsRepositoryABC(ABC):
def get_user_warnings_by_id(self, id: int) -> UserWarnings: def get_user_warnings_by_id(self, id: int) -> UserWarnings:
pass pass
@abstractmethod
def get_user_warnings_by_server_id(self, server_id: int) -> List[UserWarnings]:
pass
@abstractmethod @abstractmethod
def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]: def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]:
pass pass

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "2", "Minor": "2",
"Micro": "3" "Micro": "8"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -0,0 +1,50 @@
from typing import Optional
from cpl_core.database import DatabaseSettings
from cpl_core.database.connection import DatabaseConnectionABC
from mysql.connector.abstracts import MySQLConnectionAbstract
from mysql.connector.cursor import MySQLCursorBuffered
class DBConnection(DatabaseConnectionABC):
def __init__(self):
DatabaseConnectionABC.__init__(self)
self._database: Optional[MySQLConnectionAbstract] = None
self._cursor: Optional[MySQLCursorBuffered] = None
@property
def server(self) -> MySQLConnectionAbstract:
return self._database
@property
def cursor(self) -> MySQLCursorBuffered:
return self._cursor
def connect(self, settings: DatabaseSettings):
# connection = sql.connect(
# host=settings.host,
# port=settings.port,
# user=settings.user,
# passwd=CredentialManager.decrypt(settings.password),
# charset=settings.charset,
# use_unicode=settings.use_unicode,
# buffered=settings.buffered,
# auth_plugin=settings.auth_plugin,
# ssl_disabled=settings.ssl_disabled,
# )
# connection.cursor().execute(f"CREATE DATABASE IF NOT EXISTS `{settings.database}`;")
# self._database = sql.connect(
# host=settings.host,
# port=settings.port,
# user=settings.user,
# passwd=CredentialManager.decrypt(settings.password),
# db=settings.database,
# charset=settings.charset,
# use_unicode=settings.use_unicode,
# buffered=settings.buffered,
# auth_plugin=settings.auth_plugin,
# ssl_disabled=settings.ssl_disabled,
# )
self._
self._cursor = self._database.cursor()

View File

@ -1,9 +1,12 @@
import time import uuid
from cpl_core.database import DatabaseSettings from cpl_core.database import DatabaseSettings
from cpl_core.database.context import DatabaseContext from cpl_core.database.context import DatabaseContext
from bot_core.exception.service_error_code_enum import ServiceErrorCode
from bot_core.exception.service_exception import ServiceException
from bot_core.logging.database_logger import DatabaseLogger from bot_core.logging.database_logger import DatabaseLogger
from bot_data.mysql_pool import MySQLPool
class DBContext(DatabaseContext): class DBContext(DatabaseContext):
@ -11,36 +14,45 @@ class DBContext(DatabaseContext):
self._logger = logger self._logger = logger
DatabaseContext.__init__(self) DatabaseContext.__init__(self)
self._pool: MySQLPool = None
self._fails = 0 self._fails = 0
def connect(self, database_settings: DatabaseSettings): def connect(self, database_settings: DatabaseSettings):
try: try:
self._logger.debug(__name__, "Connecting to database") self._logger.debug(__name__, "Connecting to database")
self._db.connect(database_settings) self._pool = MySQLPool(database_settings)
self._pool.execute(f"CREATE DATABASE IF NOT EXISTS `{database_settings.database}`;", commit=True)
self._logger.info(__name__, "Connected to database") self._logger.info(__name__, "Connected to database")
except Exception as e: except Exception as e:
self._logger.fatal(__name__, "Connecting to database failed", e) self._logger.fatal(__name__, "Connecting to database failed", e)
@property
def cursor(self):
return self
def save_changes(self): def save_changes(self):
try: pass
self._logger.trace(__name__, "Save changes")
super(DBContext, self).save_changes()
self._logger.debug(__name__, "Saved changes")
except Exception as e:
self._logger.error(__name__, "Saving changes failed", e)
def select(self, statement: str) -> list[tuple]: def select(self, statement: str) -> list[tuple]:
try: try:
return super(DBContext, self).select(statement) return self._pool.execute(statement)
except Exception as e: except Exception as e:
if self._fails >= 3: if self._fails >= 3:
self._logger.fatal(__name__, f"Database error caused by {statement}", e) self._logger.error(__name__, f"Database error caused by {statement}", e)
uid = uuid.uuid4()
raise ServiceException(
ServiceErrorCode.Unknown,
f"Query failed three times with {type(e).__name__}. Contact an admin and give them the UID: {uid}",
)
self._logger.error(__name__, f"Database error caused by {statement}", e) self._logger.error(__name__, f"Database error caused by {statement}", e)
self._fails += 1 self._fails += 1
try: try:
time.sleep(0.5) self._logger.debug(__name__, "Retry select")
return self.select(statement) return self.select(statement)
except Exception as e: except Exception as e:
pass pass
return [] return []
def execute(self, statement: str):
return self._pool.execute(statement, commit=True)

View File

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

View File

@ -258,6 +258,15 @@ class AuthUser(TableABC):
""" """
) )
@property
def delete_relations_string(self) -> str:
return str(
f"""
DELETE FROM `AuthUserUsersRelations`
WHERE `AuthUserId` = {self._auth_user_id};
"""
)
@property @property
def delete_string(self) -> str: def delete_string(self) -> str:
return str( return str(

View File

@ -1,4 +1,5 @@
from datetime import datetime from datetime import datetime
from typing import Optional
from cpl_core.database import TableABC from cpl_core.database import TableABC
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
@ -48,8 +49,10 @@ class AutoRoleRule(TableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def role_name(self, bot: DiscordBotServiceABC) -> str: def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.auto_role.server.discord_id) guild = bot.get_guild(self.auto_role.server.discord_id)
if guild is None:
return None
return guild.get_role(self.role_id).name return guild.get_role(self.role_id).name
@role_id.setter @role_id.setter

View File

@ -1,3 +1,5 @@
from typing import Optional
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
@ -43,6 +45,8 @@ class AutoRoleRuleHistory(HistoryTableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def role_name(self, bot: DiscordBotServiceABC) -> str: def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.auto_role.server.discord_id) guild = bot.get_guild(self.auto_role.server.discord_id)
if guild is None:
return None
return guild.get_role(self.role_id).name return guild.get_role(self.role_id).name

View File

@ -2,6 +2,10 @@ from datetime import datetime
from typing import Optional from typing import Optional
from cpl_core.database import TableABC from cpl_core.database import TableABC
from cpl_core.dependency_injection import ServiceProviderABC
from cpl_discord.service import DiscordBotServiceABC
from cpl_query.extension import List
from discord import Role
from bot_data.model.server import Server from bot_data.model.server import Server
@ -33,6 +37,15 @@ class Level(TableABC):
def id(self) -> int: def id(self) -> int:
return self._id return self._id
@property
@ServiceProviderABC.inject
def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.server.discord_id)
if guild is None:
return None
role = List(Role, guild.roles).where(lambda x: x.name == self._name).first_or_default()
return None if role is None else role.icon
@property @property
def name(self) -> str: def name(self) -> str:
return self._name return self._name

View File

@ -1,4 +1,5 @@
from datetime import datetime from datetime import datetime
from typing import Optional
from cpl_core.database import TableABC from cpl_core.database import TableABC
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
@ -30,14 +31,18 @@ class Server(TableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def name(self, bot: DiscordBotServiceABC) -> str: def name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.discord_id) guild = bot.get_guild(self.discord_id)
if guild is None:
return None
return None if guild is None else guild.name return None if guild is None else guild.name
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def icon_url(self, bot: DiscordBotServiceABC) -> str: def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.discord_id) guild = bot.get_guild(self.discord_id)
if guild is None:
return None
return None if guild is None else guild.icon.url return None if guild is None else guild.icon.url
@staticmethod @staticmethod

View File

@ -32,6 +32,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
default_role_id: Optional[int], default_role_id: Optional[int],
short_role_name_only_set_highest_role: bool, short_role_name_only_set_highest_role: bool,
game_offer_notification_chat_id: int, game_offer_notification_chat_id: int,
reset_member_after_rejoin: bool,
feature_flags: dict[FeatureFlagsEnum], feature_flags: dict[FeatureFlagsEnum],
server: Server, server: Server,
afk_channel_ids: List[int], afk_channel_ids: List[int],
@ -58,6 +59,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
self._default_role_id = default_role_id self._default_role_id = default_role_id
self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role
self._game_offer_notification_chat_id = game_offer_notification_chat_id self._game_offer_notification_chat_id = game_offer_notification_chat_id
self._reset_member_after_rejoin = reset_member_after_rejoin
self._feature_flags = feature_flags self._feature_flags = feature_flags
self._server = server self._server = server
@ -88,6 +90,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
None, None,
False, False,
guild.system_channel.id, guild.system_channel.id,
False,
{}, {},
server, server,
List(int), List(int),
@ -234,6 +237,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
def game_offer_notification_chat_id(self, value: int): def game_offer_notification_chat_id(self, value: int):
self._game_offer_notification_chat_id = value self._game_offer_notification_chat_id = value
@property
def reset_member_after_rejoin(self) -> bool:
return self._reset_member_after_rejoin
@reset_member_after_rejoin.setter
def reset_member_after_rejoin(self, value: bool):
self._reset_member_after_rejoin = value
@property @property
def feature_flags(self) -> dict[FeatureFlagsEnum]: def feature_flags(self) -> dict[FeatureFlagsEnum]:
return self._feature_flags return self._feature_flags
@ -310,6 +321,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
`DefaultRoleId`, `DefaultRoleId`,
`ShortRoleNameSetOnlyHighest`, `ShortRoleNameSetOnlyHighest`,
`GameOfferNotificationChatId`, `GameOfferNotificationChatId`,
`ResetMemberAfterRejoin`,
`FeatureFlags`, `FeatureFlags`,
`ServerId` `ServerId`
) VALUES ( ) VALUES (
@ -330,6 +342,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
{"NULL" if self._default_role_id is None else self._default_role_id}, {"NULL" if self._default_role_id is None else self._default_role_id},
{self._short_role_name_only_set_highest_role}, {self._short_role_name_only_set_highest_role},
{self._game_offer_notification_chat_id}, {self._game_offer_notification_chat_id},
{self._reset_member_after_rejoin},
'{json.dumps(self._feature_flags)}', '{json.dumps(self._feature_flags)}',
{self._server.id} {self._server.id}
); );
@ -357,7 +370,8 @@ class ServerConfig(TableABC, ConfigurationModelABC):
`LoginMessageChannelId` = {self._login_message_channel_id}, `LoginMessageChannelId` = {self._login_message_channel_id},
`DefaultRoleId` = {"NULL" if self._default_role_id is None else self._default_role_id}, `DefaultRoleId` = {"NULL" if self._default_role_id is None else self._default_role_id},
`ShortRoleNameSetOnlyHighest` = {self._short_role_name_only_set_highest_role}, `ShortRoleNameSetOnlyHighest` = {self._short_role_name_only_set_highest_role},
`GameOfferNotificationChatId` = {self._game_offer_notification_chat_id}, `GameOfferNotificationChatId` = {"NULL" if self._game_offer_notification_chat_id is None else self._game_offer_notification_chat_id},
`ResetMemberAfterRejoin` = {self._reset_member_after_rejoin},
`FeatureFlags` = '{json.dumps(self._feature_flags)}', `FeatureFlags` = '{json.dumps(self._feature_flags)}',
`ServerId` = {self._server.id} `ServerId` = {self._server.id}
WHERE `Id` = {self._id}; WHERE `Id` = {self._id};

View File

@ -1,3 +1,5 @@
from typing import Optional
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
@ -32,12 +34,16 @@ class ServerHistory(HistoryTableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def name(self, bot: DiscordBotServiceABC) -> str: def name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.discord_id) guild = bot.get_guild(self.discord_id)
if guild is None:
return None
return None if guild is None else guild.name return None if guild is None else guild.name
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def icon_url(self, bot: DiscordBotServiceABC) -> str: def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.discord_id) guild = bot.get_guild(self.discord_id)
if guild is None:
return None
return None if guild is None else guild.icon.url return None if guild is None else guild.icon.url

View File

@ -1,4 +1,5 @@
from datetime import datetime from datetime import datetime
from typing import Optional
from cpl_core.database import TableABC from cpl_core.database import TableABC
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
@ -51,8 +52,10 @@ class ShortRoleName(TableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def role_name(self, bot: DiscordBotServiceABC) -> str: def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self._server.discord_id) guild = bot.get_guild(self._server.discord_id)
if guild is None:
return None
return guild.get_role(self.role_id).name return guild.get_role(self.role_id).name
@property @property

View File

@ -1,3 +1,5 @@
from typing import Optional
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
@ -47,8 +49,10 @@ class ShortRoleNameHistory(HistoryTableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def role_name(self, bot: DiscordBotServiceABC) -> str: def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self._server.discord_id) guild = bot.get_guild(self._server.discord_id)
if guild is None:
return None
return guild.get_role(self.role_id).name return guild.get_role(self.role_id).name
@property @property

View File

@ -38,6 +38,11 @@ class User(TableABC):
self._created_at = created_at if created_at is not None else self._created_at self._created_at = created_at if created_at is not None else self._created_at
self._modified_at = modified_at if modified_at is not None else self._modified_at self._modified_at = modified_at if modified_at is not None else self._modified_at
def reset(self):
self._xp = 0
self._message_count = 0
self._reaction_count = 0
@property @property
def id(self) -> int: def id(self) -> int:
return self._user_id return self._user_id
@ -48,15 +53,19 @@ class User(TableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def name(self, bot: DiscordBotServiceABC) -> str: def name(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.server.discord_id) guild = bot.get_guild(self.server.discord_id)
if guild is None:
return None
user = guild.get_member(self.discord_id) user = guild.get_member(self.discord_id)
return None if user is None else user.name return None if user is None else user.name
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def icon_url(self, bot: DiscordBotServiceABC) -> str: def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.server.discord_id) guild = bot.get_guild(self.server.discord_id)
if guild is None:
return None
user = guild.get_member(self.discord_id) user = guild.get_member(self.discord_id)
return None if user is None else user.display_icon return None if user is None else user.display_icon
@ -132,7 +141,7 @@ class User(TableABC):
@property @property
@ServiceProviderABC.inject @ServiceProviderABC.inject
def level(self, services: ServiceProviderABC) -> Level: def level(self, services: ServiceProviderABC) -> Optional[Level]:
from modules.level.service.level_service import LevelService from modules.level.service.level_service import LevelService
levels: LevelService = services.get_service(LevelService) levels: LevelService = services.get_service(LevelService)
@ -168,6 +177,15 @@ class User(TableABC):
game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC) game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC)
return game_idents_repo.get_user_game_idents_by_user_id(self.id) return game_idents_repo.get_user_game_idents_by_user_id(self.id)
@property
@ServiceProviderABC.inject
def profile_picture_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
guild = bot.get_guild(self.server.discord_id)
if guild is None:
return None
user = guild.get_member(self._discord_id)
return None if user is None or user.avatar is None else user.avatar.url
@staticmethod @staticmethod
def get_select_all_string() -> str: def get_select_all_string() -> str:
return str( return str(

View File

@ -59,6 +59,17 @@ class UserWarnings(TableABC):
""" """
) )
@staticmethod
def get_select_by_server_id_string(id: int) -> str:
return str(
f"""
SELECT `UserWarnings`.* FROM `UserWarnings`
INNER JOIN `Users`
ON `Users`.`UserId` = `UserWarnings`.`UserId`
WHERE `Users`.`ServerId` = {id};
"""
)
@staticmethod @staticmethod
def get_select_by_user_id_string(id: int) -> str: def get_select_by_user_id_string(id: int) -> str:
return str( return str(

View File

@ -0,0 +1,104 @@
# https://stackoverflow.com/questions/32658679/how-to-create-a-mysql-connection-pool-or-any-better-way-to-initialize-the-multip
import mysql.connector as sql
from cpl_core.database import DatabaseSettings
from cpl_core.utils import CredentialManager
class MySQLPool(object):
"""
create a pool when connect mysql, which will decrease the time spent in
request connection, create connection and close connection.
"""
def __init__(
self,
database_settings: DatabaseSettings,
pool_size=5,
):
res = {
"host": database_settings.host,
"port": database_settings.port,
"user": database_settings.user,
"password": CredentialManager.decrypt(database_settings.password),
"database": database_settings.database,
}
self.dbconfig = res
self.pool = self.create_pool(pool_name="MySqlPool", pool_size=pool_size)
def create_pool(self, pool_name="MySqlPool", pool_size=3):
"""
Create a connection pool, after created, the request of connecting
MySQL could get a connection from this pool instead of request to
create a connection.
:param pool_name: the name of pool, default is "mypool"
:param pool_size: the size of pool, default is 3
:return: connection pool
"""
pool = sql.pooling.MySQLConnectionPool(
pool_name=pool_name, pool_size=pool_size, pool_reset_session=True, **self.dbconfig
)
return pool
def close(self, conn, cursor):
"""
A method used to close connection of mysql.
:param conn:
:param cursor:
:return:
"""
cursor.close()
conn.close()
def execute(self, sql, args=None, commit=False):
"""
Execute a sql, it could be with args and with out args. The usage is
similar with execute() function in module pymysql.
:param sql: sql clause
:param args: args need by sql clause
:param commit: whether to commit
:return: if commit, return None, else, return result
"""
# get connection form connection pool instead of create one.
conn = self.pool.get_connection()
cursor = conn.cursor()
if args:
cursor.execute(sql, args)
else:
cursor.execute(sql)
if commit is True:
conn.commit()
self.close(conn, cursor)
return None
else:
res = cursor.fetchall()
self.close(conn, cursor)
return res
def executemany(self, sql, args, commit=False):
"""
Execute with many args. Similar with executemany() function in pymysql.
args should be a sequence.
:param sql: sql clause
:param args: args
:param commit: commit or not.
:return: if commit, return None, else, return result
"""
# get connection form connection pool instead of create one.
conn = self.pool.get_connection()
cursor = conn.cursor()
cursor.executemany(sql, args)
if commit is True:
conn.commit()
self.close(conn, cursor)
return None
else:
res = cursor.fetchall()
self.close(conn, cursor)
return res
def commit(self):
conn = self.pool.get_connection()
conn.commit()
cursor = conn.cursor()
self.close(conn, cursor)

View File

@ -0,0 +1,7 @@
ALTER TABLE CFG_Server
DROP COLUMN ResetMemberAfterRejoin;
ALTER TABLE CFG_ServerHistory
DROP COLUMN ResetMemberAfterRejoin;

View File

@ -0,0 +1,116 @@
ALTER TABLE CFG_Server
ADD ResetMemberAfterRejoin BOOLEAN NOT NULL DEFAULT FALSE AFTER GameOfferNotificationChatId;
ALTER TABLE CFG_ServerHistory
ADD ResetMemberAfterRejoin BOOLEAN NOT NULL DEFAULT FALSE AFTER GameOfferNotificationChatId;
DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;;
CREATE TRIGGER `TR_CFG_ServerUpdate`
AFTER UPDATE
ON `CFG_Server`
FOR EACH ROW
BEGIN
INSERT INTO `CFG_ServerHistory` (`Id`,
`MessageDeleteTimer`,
`NotificationChatId`,
`MaxVoiceStateHours`,
`XpPerMessage`,
`XpPerReaction`,
`MaxMessageXpPerHour`,
`XpPerOntimeHour`,
`XpPerEventParticipation`,
`XpPerAchievement`,
`AFKCommandChannelId`,
`HelpVoiceChannelId`,
`TeamChannelId`,
`LoginMessageChannelId`,
`DefaultRoleId`,
`ShortRoleNameSetOnlyHighest`,
`GameOfferNotificationChatId`,
`ResetMemberAfterRejoin`,
`FeatureFlags`,
`ServerId`,
`DateFrom`,
`DateTo`)
VALUES (OLD.Id,
OLD.MessageDeleteTimer,
OLD.NotificationChatId,
OLD.MaxVoiceStateHours,
OLD.XpPerMessage,
OLD.XpPerReaction,
OLD.MaxMessageXpPerHour,
OLD.XpPerOntimeHour,
OLD.XpPerEventParticipation,
OLD.XpPerAchievement,
OLD.AFKCommandChannelId,
OLD.HelpVoiceChannelId,
OLD.TeamChannelId,
OLD.LoginMessageChannelId,
OLD.DefaultRoleId,
OLD.ShortRoleNameSetOnlyHighest,
OLD.GameOfferNotificationChatId,
OLD.ResetMemberAfterRejoin,
OLD.FeatureFlags,
OLD.ServerId,
OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6));
END;;
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;;
CREATE TRIGGER `TR_CFG_ServerDelete`
AFTER DELETE
ON `CFG_Server`
FOR EACH ROW
BEGIN
INSERT INTO `CFG_ServerHistory` (`Id`,
`MessageDeleteTimer`,
`NotificationChatId`,
`MaxVoiceStateHours`,
`XpPerMessage`,
`XpPerReaction`,
`MaxMessageXpPerHour`,
`XpPerOntimeHour`,
`XpPerEventParticipation`,
`XpPerAchievement`,
`AFKCommandChannelId`,
`HelpVoiceChannelId`,
`TeamChannelId`,
`LoginMessageChannelId`,
`DefaultRoleId`,
`ShortRoleNameSetOnlyHighest`,
`GameOfferNotificationChatId`,
`ResetMemberAfterRejoin`,
`ServerId`,
`FeatureFlags`,
`Deleted`,
`DateFrom`,
`DateTo`)
VALUES (OLD.Id,
OLD.MessageDeleteTimer,
OLD.NotificationChatId,
OLD.MaxVoiceStateHours,
OLD.XpPerMessage,
OLD.XpPerReaction,
OLD.MaxMessageXpPerHour,
OLD.XpPerOntimeHour,
OLD.XpPerEventParticipation,
OLD.XpPerAchievement,
OLD.AFKCommandChannelId,
OLD.HelpVoiceChannelId,
OLD.TeamChannelId,
OLD.LoginMessageChannelId,
OLD.DefaultRoleId,
OLD.ShortRoleNameSetOnlyHighest,
OLD.GameOfferNotificationChatId,
OLD.ResetMemberAfterRejoin,
OLD.FeatureFlags,
OLD.ServerId,
TRUE,
OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6));
END;;

View File

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

View File

@ -164,6 +164,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
def delete_auth_user(self, user: AuthUser): def delete_auth_user(self, user: AuthUser):
self._logger.trace(__name__, f"Send SQL command: {user.delete_string}") self._logger.trace(__name__, f"Send SQL command: {user.delete_string}")
self._context.cursor.execute(user.delete_relations_string)
self._context.cursor.execute(user.delete_string) self._context.cursor.execute(user.delete_string)
def add_auth_user_user_rel(self, rel: AuthUserUsersRelation): def add_auth_user_user_rel(self, rel: AuthUserUsersRelation):

View File

@ -37,6 +37,8 @@ class LevelRepositoryService(LevelRepositoryABC):
int(self._get_value_from_result(sql_result[3])), # min xp int(self._get_value_from_result(sql_result[3])), # min xp
int(self._get_value_from_result(sql_result[4])), # permissions int(self._get_value_from_result(sql_result[4])), # permissions
self._servers.get_server_by_id(sql_result[5]), # server self._servers.get_server_by_id(sql_result[5]), # server
sql_result[6], # created_at
sql_result[7], # modified_at
id=self._get_value_from_result(sql_result[0]), # id id=self._get_value_from_result(sql_result[0]), # id
) )

View File

@ -1,13 +1,13 @@
import glob import glob
import os import os
from cpl_core.database.context import DatabaseContextABC
from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.dependency_injection import ServiceProviderABC
from cpl_query.extension import List from cpl_query.extension import List
from packaging import version from packaging import version
import bot import bot
from bot_core.logging.database_logger import DatabaseLogger from bot_core.logging.database_logger import DatabaseLogger
from bot_data.db_context import DBContext
from bot_data.model.migration import Migration from bot_data.model.migration import Migration
from bot_data.model.migration_history import MigrationHistory from bot_data.model.migration_history import MigrationHistory
@ -17,13 +17,12 @@ class MigrationService:
self, self,
logger: DatabaseLogger, logger: DatabaseLogger,
services: ServiceProviderABC, services: ServiceProviderABC,
db: DatabaseContextABC, db: DBContext,
): ):
self._logger = logger self._logger = logger
self._services = services self._services = services
self._db = db self._db = db
self._cursor = db.cursor
def _get_migration_history(self) -> List[MigrationHistory]: def _get_migration_history(self) -> List[MigrationHistory]:
results = self._db.select( results = self._db.select(
@ -42,7 +41,7 @@ class MigrationService:
return return
self._logger.debug(__name__, f"Migrate new migration {migration.migration_id} to old method") self._logger.debug(__name__, f"Migrate new migration {migration.migration_id} to old method")
self._cursor.execute(migration.change_id_string(f"{migration.migration_id}Migration")) self._db.execute(migration.change_id_string(f"{migration.migration_id}Migration"))
self._db.save_changes() self._db.save_changes()
def _migration_migrations_to_new(self, migration: MigrationHistory): def _migration_migrations_to_new(self, migration: MigrationHistory):
@ -50,12 +49,11 @@ class MigrationService:
return return
self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method") self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method")
self._cursor.execute(migration.change_id_string(migration.migration_id.replace("Migration", ""))) self._db.execute(migration.change_id_string(migration.migration_id.replace("Migration", "")))
self._db.save_changes() self._db.save_changes()
def _migrate_from_old_to_new(self): def _migrate_from_old_to_new(self):
self._cursor.execute("SHOW TABLES LIKE 'MigrationHistory'") result = self._db.select("SHOW TABLES LIKE 'MigrationHistory'")
result = self._cursor.fetchone()
if not result: if not result:
return return
@ -120,8 +118,7 @@ class MigrationService:
active_statement = "" active_statement = ""
try: try:
# check if table exists # check if table exists
self._cursor.execute("SHOW TABLES LIKE 'MigrationHistory'") result = self._db.select("SHOW TABLES LIKE 'MigrationHistory'")
result = self._cursor.fetchone()
if result: if result:
# there is a table named "tableName" # there is a table named "tableName"
self._logger.trace( self._logger.trace(
@ -142,9 +139,9 @@ class MigrationService:
if statement in ["", "\n"]: if statement in ["", "\n"]:
continue continue
active_statement = statement active_statement = statement
self._cursor.execute(statement + ";") self._db.execute(statement + ";")
self._cursor.execute( self._db.execute(
MigrationHistory(migration.name).insert_string MigrationHistory(migration.name).insert_string
if upgrade if upgrade
else MigrationHistory(migration.name).delete_string else MigrationHistory(migration.name).delete_string

View File

@ -79,12 +79,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
result[15], result[15],
result[16], result[16],
result[17], result[17],
json.loads(result[18]), result[18],
self._servers.get_server_by_id(result[19]), json.loads(result[19]),
self._get_afk_channel_ids(result[19]), self._servers.get_server_by_id(result[20]),
self._get_team_role_ids(result[19]), self._get_afk_channel_ids(result[20]),
result[20], self._get_team_role_ids(result[20]),
result[21], result[21],
result[22],
id=result[0], id=result[0],
) )

View File

@ -2,6 +2,7 @@ from datetime import datetime
from typing import Optional from typing import Optional
from cpl_core.database.context import DatabaseContextABC from cpl_core.database.context import DatabaseContextABC
from cpl_core.time import TimeFormatSettings
from cpl_query.extension import List from cpl_query.extension import List
from bot_core.logging.database_logger import DatabaseLogger from bot_core.logging.database_logger import DatabaseLogger
@ -15,12 +16,14 @@ from bot_data.model.user_message_count_per_hour import UserMessageCountPerHour
class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepositoryABC): class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepositoryABC):
def __init__( def __init__(
self, self,
time_format: TimeFormatSettings,
logger: DatabaseLogger, logger: DatabaseLogger,
db_context: DatabaseContextABC, db_context: DatabaseContextABC,
users: UserRepositoryABC, users: UserRepositoryABC,
): ):
UserMessageCountPerHourRepositoryABC.__init__(self) UserMessageCountPerHourRepositoryABC.__init__(self)
self._time_format = time_format
self._logger = logger self._logger = logger
self._context = db_context self._context = db_context
self._users = users self._users = users
@ -67,7 +70,12 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository
) -> UserMessageCountPerHour: ) -> UserMessageCountPerHour:
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date) sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
self._logger.trace(__name__, f"Send SQL command: {sql}") self._logger.trace(__name__, f"Send SQL command: {sql}")
return self._from_result(self._context.select(sql)[0]) res = self._context.select(sql)
if len(res) > 0:
return self._from_result(res[0])
user = self._users.get_user_by_id(user_id)
return UserMessageCountPerHour(date.strftime(self._time_format.date_time_format), date.hour, 0, user)
def find_user_message_count_per_hour_by_user_id_and_date( def find_user_message_count_per_hour_by_user_id_and_date(
self, user_id: int, date: datetime self, user_id: int, date: datetime

View File

@ -56,6 +56,20 @@ class UserWarningsRepositoryService(UserWarningsRepositoryABC):
self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_by_id_string(id)}") self._logger.trace(__name__, f"Send SQL command: {UserWarnings.get_select_by_id_string(id)}")
return self._from_result(self._context.select(UserWarnings.get_select_by_id_string(id))[0]) return self._from_result(self._context.select(UserWarnings.get_select_by_id_string(id))[0])
def get_user_warnings_by_server_id(self, server_id: int) -> List[UserWarnings]:
self._logger.trace(
__name__,
f"Send SQL command: {UserWarnings.get_select_by_server_id_string(server_id)}",
)
return List(
UserWarnings,
[
self._from_result(warning)
for warning in self._context.select(UserWarnings.get_select_by_server_id_string(server_id))
],
)
def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]: def get_user_warnings_by_user_id(self, user_id: int) -> List[UserWarnings]:
self._logger.trace( self._logger.trace(
__name__, __name__,

View File

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

View File

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

View File

@ -7,8 +7,8 @@ from cpl_core.type import T
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from cpl_query.extension import List from cpl_query.extension import List
from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_core.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException from bot_core.exception.service_exception import ServiceException
from bot_api.route.route import Route from bot_api.route.route import Route
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_core.environment_variables import MAINTENANCE from bot_core.environment_variables import MAINTENANCE
@ -30,6 +30,7 @@ from bot_data.model.user_joined_game_server import UserJoinedGameServer
from bot_data.model.user_joined_server import UserJoinedServer from bot_data.model.user_joined_server import UserJoinedServer
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
from bot_data.model.user_role_enum import UserRoleEnum from bot_data.model.user_role_enum import UserRoleEnum
from bot_data.model.user_warnings import UserWarnings
from bot_graphql.abc.filter_abc import FilterABC from bot_graphql.abc.filter_abc import FilterABC
from bot_graphql.filter.page import Page from bot_graphql.filter.page import Page
from bot_graphql.filter.sort import Sort from bot_graphql.filter.sort import Sort
@ -90,7 +91,7 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if permissions.is_member_technician(guild.get_member(u.discord_id)): if guild is not None and permissions.is_member_technician(guild.get_member(u.discord_id)):
return True return True
if config.get_configuration(MAINTENANCE): if config.get_configuration(MAINTENANCE):
@ -101,9 +102,7 @@ class QueryABC(ObjectType):
element: Achievement = element element: Achievement = element
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) if u.server.id == element.server.id:
member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
access = True access = True
break break
@ -112,6 +111,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member) and u.server.id == element.server.id: if permissions.is_member_moderator(member) and u.server.id == element.server.id:
access = True access = True
@ -122,6 +123,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member) and u.server.id == element.auto_role.server.id: if permissions.is_member_moderator(member) and u.server.id == element.auto_role.server.id:
access = True access = True
@ -138,6 +141,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member): if permissions.is_member_moderator(member):
access = True access = True
@ -161,15 +166,30 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if u.id == element.id or permissions.is_member_moderator(member): if u.id == element.id or permissions.is_member_moderator(member):
access = True access = True
break break
elif type(element) == UserWarnings:
for u in user.users:
u: User = u
guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id)
if u.id == element.user.id or permissions.is_member_moderator(member):
access = True
break
elif type(element) == UserJoinedServer: elif type(element) == UserJoinedServer:
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if u.id == element.user.id or permissions.is_member_moderator(member): if u.id == element.user.id or permissions.is_member_moderator(member):
access = True access = True
@ -179,6 +199,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if u.id == element.user.id or permissions.is_member_moderator(member): if u.id == element.user.id or permissions.is_member_moderator(member):
access = True access = True
@ -188,6 +210,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if u.id == element.user.id or permissions.is_member_moderator(member): if u.id == element.user.id or permissions.is_member_moderator(member):
access = True access = True
@ -197,6 +221,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_technician(member): if permissions.is_member_technician(member):
access = True access = True
@ -207,6 +233,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member) and u.server.id == element.server.id: if permissions.is_member_moderator(member) and u.server.id == element.server.id:
access = True access = True
@ -217,6 +245,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member) and u.server.id == element.server.id: if permissions.is_member_moderator(member) and u.server.id == element.server.id:
access = True access = True
@ -226,6 +256,8 @@ class QueryABC(ObjectType):
for u in user.users: for u in user.users:
u: User = u u: User = u
guild = bot.get_guild(u.server.discord_id) guild = bot.get_guild(u.server.discord_id)
if guild is None:
continue
member = guild.get_member(u.discord_id) member = guild.get_member(u.discord_id)
if permissions.is_member_technician(member): if permissions.is_member_technician(member):
access = True access = True

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "2", "Minor": "2",
"Micro": "3" "Micro": "8"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

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

View File

@ -51,6 +51,8 @@ class AutoRoleRuleFilter(FilterABC):
def get_role_name(x: AutoRoleRule): def get_role_name(x: AutoRoleRule):
guild = self._bot.get_guild(x.auto_role.server.discord_id) guild = self._bot.get_guild(x.auto_role.server.discord_id)
if guild is None:
return False
name = guild.get_role(x.role_id).name name = guild.get_role(x.role_id).name
return name == self._role_name or self._role_name in name return name == self._role_name or self._role_name in name

View File

@ -57,6 +57,8 @@ class ShortRoleNameFilter(FilterABC):
def get_role_name(x: ShortRoleName): def get_role_name(x: ShortRoleName):
guild = self._bot.get_guild(x.server.discord_id) guild = self._bot.get_guild(x.server.discord_id)
if guild is None:
return False
name = guild.get_role(x.role_id).name name = guild.get_role(x.role_id).name
return name == self._role_name or self._role_name in name return name == self._role_name or self._role_name in name

View File

@ -80,6 +80,8 @@ class UserFilter(FilterABC):
def _get_member(user: User): def _get_member(user: User):
guild = self._bot.get_guild(user.server.discord_id) guild = self._bot.get_guild(user.server.discord_id)
if guild is None:
return False
member = guild.get_member(user.discord_id) member = guild.get_member(user.discord_id)
return member is not None and (member.name == self._name or self._name in member.name) return member is not None and (member.name == self._name or self._name in member.name)

View File

@ -44,7 +44,7 @@ class UserWarningFilter(FilterABC):
if self._user is not None: if self._user is not None:
users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id) users = self._user.filter(query.select(lambda x: x.user)).select(lambda x: x.id)
query = query.where(lambda x: x.id in users) query = query.where(lambda x: x.user.id in users)
if self._description is not None: if self._description is not None:
query = query.where(lambda x: x.description == self._description or self._description in x.description) query = query.where(lambda x: x.description == self._description or self._description in x.description)

View File

@ -1,5 +1,6 @@
type Level implements TableWithHistoryQuery { type Level implements TableWithHistoryQuery {
id: ID id: ID
iconURL: String
name: String name: String
color: String color: String
minXp: Int minXp: Int

View File

@ -29,6 +29,9 @@ type Server implements TableWithHistoryQuery {
activeUserCount: Int activeUserCount: Int
users(filter: UserFilter, page: Page, sort: Sort): [User] users(filter: UserFilter, page: Page, sort: Sort): [User]
userWarningCount: Int
userWarnings(filter: UserWarningFilter, page: Page, sort: Sort): [UserWarning]
achievementCount: Int achievementCount: Int
achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement] achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement]

View File

@ -17,6 +17,7 @@ type ServerConfig implements TableWithHistoryQuery {
defaultRoleId: String defaultRoleId: String
shortRoleNameOnlySetHighestRole: Boolean shortRoleNameOnlySetHighestRole: Boolean
gameOfferNotificationChatId: String gameOfferNotificationChatId: String
resetMemberAfterRejoin: Boolean
featureFlagCount: Int featureFlagCount: Int
featureFlags: [FeatureFlag] featureFlags: [FeatureFlag]
@ -50,7 +51,7 @@ type ServerConfigHistory implements HistoryTableQuery {
loginMessageChannelId: String loginMessageChannelId: String
defaultRoleId: String defaultRoleId: String
shortRoleNameOnlySetHighestRole: Boolean shortRoleNameOnlySetHighestRole: Boolean
gameOfferNotificationChatId: String resetMemberAfterRejoin: Boolean
featureFlagCount: Int featureFlagCount: Int
featureFlags: [FeatureFlag] featureFlags: [FeatureFlag]
@ -103,6 +104,7 @@ input ServerConfigInput {
defaultRoleId: String defaultRoleId: String
shortRoleNameOnlySetHighestRole: Boolean shortRoleNameOnlySetHighestRole: Boolean
gameOfferNotificationChatId: String gameOfferNotificationChatId: String
resetMemberAfterRejoin: Boolean
featureFlags: [FeatureFlagInput] featureFlags: [FeatureFlagInput]
afkChannelIds: [String] afkChannelIds: [String]

View File

@ -11,6 +11,8 @@ type User implements TableWithHistoryQuery {
level: Level level: Level
activityScore: Int activityScore: Int
profilePictureURL: String
joinedServers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [UserJoinedServer] joinedServers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [UserJoinedServer]
joinedServerCount: Int joinedServerCount: Int

View File

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

View File

@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
__author__ = "Sven Heidemann" __author__ = "Sven Heidemann"
__license__ = "MIT" __license__ = "MIT"
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" __copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
__version__ = "1.2.3" __version__ = "1.2.8"
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple("VersionInfo", "major minor micro") VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="1", minor="2", micro="3") version_info = VersionInfo(major="1", minor="2", micro="8")

View File

@ -105,6 +105,11 @@ class ServerConfigMutation(QueryABC):
if "gameOfferNotificationChatId" in input if "gameOfferNotificationChatId" in input
else server_config.game_offer_notification_chat_id else server_config.game_offer_notification_chat_id
) )
server_config.reset_member_after_rejoin = (
input["resetMemberAfterRejoin"]
if "resetMemberAfterRejoin" in input
else server_config.reset_member_after_rejoin
)
server_config.feature_flags = ( server_config.feature_flags = (
dict( dict(
zip( zip(

View File

@ -7,6 +7,7 @@ from bot_data.model.short_role_name import ShortRoleName
from bot_data.model.user_role_enum import UserRoleEnum from bot_data.model.user_role_enum import UserRoleEnum
from bot_graphql.abc.query_abc import QueryABC from bot_graphql.abc.query_abc import QueryABC
from bot_core.service.permission_service import PermissionService from bot_core.service.permission_service import PermissionService
from modules.short_role_name.service.short_role_name_service import ShortRoleNameService
class ShortRoleNameMutation(QueryABC): class ShortRoleNameMutation(QueryABC):
@ -17,6 +18,7 @@ class ShortRoleNameMutation(QueryABC):
bot: DiscordBotServiceABC, bot: DiscordBotServiceABC,
db: DatabaseContextABC, db: DatabaseContextABC,
permissions: PermissionService, permissions: PermissionService,
short_role_name_service: ShortRoleNameService,
): ):
QueryABC.__init__(self, "ShortRoleNameMutation") QueryABC.__init__(self, "ShortRoleNameMutation")
@ -25,6 +27,7 @@ class ShortRoleNameMutation(QueryABC):
self._bot = bot self._bot = bot
self._db = db self._db = db
self._permissions = permissions self._permissions = permissions
self._short_role_name_service = short_role_name_service
self.set_field("createShortRoleName", self.resolve_create_short_role_name) self.set_field("createShortRoleName", self.resolve_create_short_role_name)
self.set_field("updateShortRoleName", self.resolve_update_short_role_name) self.set_field("updateShortRoleName", self.resolve_update_short_role_name)
@ -79,6 +82,7 @@ class ShortRoleNameMutation(QueryABC):
short_role_name = self._short_role_names.get_short_role_name_by_id(id) short_role_name = self._short_role_names.get_short_role_name_by_id(id)
self._can_user_mutate_data(short_role_name.server, UserRoleEnum.admin) self._can_user_mutate_data(short_role_name.server, UserRoleEnum.admin)
self._bot.loop.create_task(self._short_role_name_service.remove_short_role_from_members(short_role_name))
self._short_role_names.delete_short_role_name(short_role_name) self._short_role_names.delete_short_role_name(short_role_name)
self._db.save_changes() self._db.save_changes()

View File

@ -11,6 +11,7 @@ from flask import request
from bot_api.configuration.authentication_settings import AuthenticationSettings from bot_api.configuration.authentication_settings import AuthenticationSettings
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
from bot_core.service.permission_service import PermissionService
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC
@ -24,7 +25,6 @@ from bot_data.model.server_config import ServerConfig
from bot_data.model.user_joined_game_server import UserJoinedGameServer from bot_data.model.user_joined_game_server import UserJoinedGameServer
from bot_data.model.user_role_enum import UserRoleEnum from bot_data.model.user_role_enum import UserRoleEnum
from bot_graphql.abc.query_abc import QueryABC from bot_graphql.abc.query_abc import QueryABC
from bot_core.service.permission_service import PermissionService
class UserJoinedGameServerMutation(QueryABC): class UserJoinedGameServerMutation(QueryABC):
@ -79,7 +79,10 @@ class UserJoinedGameServerMutation(QueryABC):
) )
def resolve_user_joined(self, *_, input: dict): def resolve_user_joined(self, *_, input: dict):
game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"]) game_ident = self._user_game_idents.find_user_game_ident_by_ident(input["ident"])
if game_ident is None:
return
user = game_ident.user user = game_ident.user
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}")

View File

@ -4,6 +4,7 @@ from cpl_core.database.context import DatabaseContextABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from bot_api.route.route import Route from bot_api.route.route import Route
from bot_core.service.permission_service import PermissionService
from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC
@ -13,7 +14,6 @@ from bot_data.model.user_role_enum import UserRoleEnum
from bot_graphql.abc.query_abc import QueryABC from bot_graphql.abc.query_abc import QueryABC
from modules.base.service.user_warnings_service import UserWarningsService from modules.base.service.user_warnings_service import UserWarningsService
from modules.level.service.level_service import LevelService from modules.level.service.level_service import LevelService
from bot_core.service.permission_service import PermissionService
class UserMutation(QueryABC): class UserMutation(QueryABC):
@ -50,7 +50,7 @@ class UserMutation(QueryABC):
member = self._bot.get_guild(user.server.discord_id).get_member( member = self._bot.get_guild(user.server.discord_id).get_member(
auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id auth_user.users.where(lambda x: x.server.id == user.server.id).single().discord_id
) )
if member.id != user.discord_id: if self._permissions.is_member_moderator(member) or member.id != user.discord_id:
self._can_user_mutate_data(user.server, UserRoleEnum.moderator) self._can_user_mutate_data(user.server, UserRoleEnum.moderator)
new_xp = None new_xp = None
@ -86,5 +86,9 @@ class UserMutation(QueryABC):
continue continue
member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id) member = self._bot.get_guild(user.server.discord_id).get_member(user.discord_id)
author = self._users.get_user_by_id(int(warning["author"])) if "author" not in warning:
author = Route.get_user().users.where(lambda u: u.server.id == user.server.id).single()
else:
author = self._users.get_user_by_id(int(warning["author"]))
self._user_warning_service.add_warnings(member, warning["description"], author.discord_id) self._user_warning_service.add_warnings(member, warning["description"], author.discord_id)

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