Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: activation is the new registration #1892

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ MH_SMTP_BIND_ADDR=0.0.0.0:25
# Settings for Pwned Passwords API to check if passwords are present in known breaches
PWNED_PASSWORDS_HOST=https://pwned-passwords.gewis.nl/api

# Settings for GEWISDB API health check
GEWISDB_API_HOST=https://database.test.gewis.nl/api
GEWISDB_API_KEY='thiskeyisnotvalid'

# Google Calendar API (Option Calendar) settings
DOCKER_GOOGLE_API_KEY=unknown
DOCKER_GOOGLE_CALENDAR_KEY=unknown
Expand Down
2 changes: 1 addition & 1 deletion docker/web/development/crontab
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# * * * * * command to execute
# Don't remove the empty line at the end of this file. It is required to run the cron job
# 0 0 * * 1 { . /code/config/bash.env && /usr/local/bin/php /code/web photo:weeklyphoto; } > /code/data/logs/cron-weeklyphoto.log 2>&1
# 58 1 * * * { . /code/config/bash.env && /usr/local/bin/php /code/importdb.php; } > /code/data/logs/cron-importdb.log 2>&1
# 28,58 * * * * { . /code/config/bash.env && /usr/local/bin/php /code/importdb.php; } > /code/data/logs/cron-importdb.log 2>&1
# 0 23 * * * { . /code/config/bash.env && /usr/local/bin/php /code/web activity:calendar:notify; } > /code/data/logs/cron-activitycalendar.log 2>&1
# 0 * * * * { . /code/config/bash.env && /code/publicarchive.sh; } > /code/data/logs/cron-publicarchive.log 2>&1
# Automated GDPR related tasks below:
Expand Down
2 changes: 1 addition & 1 deletion docker/web/production/crontab
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# * * * * * command to execute
# Don't remove the empty line at the end of this file. It is required to run the cron job
0 0 * * 1 { . /code/config/bash.env && /usr/local/bin/php /code/web photo:weeklyphoto; } > /code/data/logs/cron-weeklyphoto.log 2>&1
58 1 * * * { . /code/config/bash.env && /usr/local/bin/php /code/importdb.php; } > /code/data/logs/cron-importdb.log 2>&1
28,58 * * * * { . /code/config/bash.env && /usr/local/bin/php /code/importdb.php; } > /code/data/logs/cron-importdb.log 2>&1
0 23 * * * { . /code/config/bash.env && /usr/local/bin/php /code/web activity:calendar:notify; } > /code/data/logs/cron-activitycalendar.log 2>&1
0 * * * * { . /code/config/bash.env && /code/publicarchive.sh; } > /code/data/logs/cron-publicarchive.log 2>&1
# Automated GDPR related tasks below:
Expand Down
63 changes: 62 additions & 1 deletion importdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,68 @@
* It is a simple PostgreSQL to MySQL copy script.
*/

$apiKey = getenv('GEWISDB_API_KEY');
$apiHost = getenv('GEWISDB_API_HOST');

if (
false === $apiKey
|| false === $apiHost
) {
echo 'API: no sync, environment variables are not set properly...' . PHP_EOL;
exit(1);
}

$ch = curl_init();

$headers = [
sprintf('Authorization: Bearer %s', $apiKey),
];

curl_setopt($ch, CURLOPT_URL, $apiHost . '/health');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$response = curl_exec($ch);

if (false === $response) {
echo 'API: no sync, unexpected cURL error...' . PHP_EOL;
curl_close($ch);
exit(1);
}

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if (
200 === $httpCode
|| 403 === $httpCode
) {
if (!json_validate($response)) {
echo 'API: no sync, invalid JSON returned...' . PHP_EOL;
curl_close($ch);
exit(1);
}

$health = json_decode($response, true);

if (
$health['healthy']
&& !$health['sync_paused']
) {
echo 'API: sync, healthy and syncs are allowed...' . PHP_EOL;
} else {
echo 'API: no sync, sync is paused or API is not healthy...' . PHP_EOL;
curl_close($ch);
exit(1);
}
} else {
echo 'API: no sync, unexpected response...' . PHP_EOL;
curl_close($ch);
exit(1);
}

curl_close($ch);

echo 'Commencing sync with GEWISDB...' . PHP_EOL;

try {
Expand Down Expand Up @@ -182,7 +244,6 @@ function ($a) use ($i) {
/**
* Removing old data
*/

// Tables without primary keys are skipped
if (0 === count($pks[$table])) continue;

Expand Down
38 changes: 28 additions & 10 deletions module/Application/language/en.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions module/Application/language/gewisweb.pot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 29 additions & 10 deletions module/Application/language/nl.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading