From 55f1ba28e48ab5bce75d8dffd66f6ecc48d5bb28 Mon Sep 17 00:00:00 2001 From: Tom Udding Date: Mon, 13 Mar 2023 19:47:24 +0100 Subject: [PATCH 1/2] Add local Mailman 3 instance To create the superuser for configuration things in Postorius, execute `python manage.py createsuperuser` in the `mailman-web` container. This does not add authentication for the API endpoint. --- .env.dist | 1 + .gitignore | 3 ++ docker-compose.override.yml | 41 ++++++++++++++++++- ...database.sh => create-gewisdb-database.sh} | 2 + 4 files changed, 46 insertions(+), 1 deletion(-) rename docker/pgadmin/{create-gewisdb_report-database.sh => create-gewisdb-database.sh} (62%) diff --git a/.env.dist b/.env.dist index b28729119..29bbfa6a0 100644 --- a/.env.dist +++ b/.env.dist @@ -67,6 +67,7 @@ LDAP_BASEDN= # These are the environment variables for Postgres, only used in docker-compose.override.yaml for development POSTGRES_PASSWORD=gewisdb POSTGRES_USER=gewisdb +POSTGRES_MAILMAN_DATABASE=gewisdb_mailman PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org PGADMIN_DEFAULT_PASSWORD=pgadmin PGADMIN_DISABLE_POSTFIX=true diff --git a/.gitignore b/.gitignore index 843c7af54..674951d94 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ phpcs.xml # Language binaries are created during the docker build process or using 'make compilelang' *.mo + +# Local mailman data for development +mailman/ diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 517547153..8f3e85faf 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -5,7 +5,7 @@ services: - .env volumes: - gewisdb_postgresql:/var/lib/postgresql/data:rw - - ./docker/pgadmin/create-gewisdb_report-database.sh:/docker-entrypoint-initdb.d/create-database.sh + - ./docker/pgadmin/create-gewisdb-database.sh:/docker-entrypoint-initdb.d/create-database.sh networks: - gewisdb_network ports: @@ -29,8 +29,46 @@ services: image: mailhog/mailhog ports: - "8025:8025" + mailman-core: + image: maxking/mailman-core:0.4 + container_name: mailman-core + hostname: mailman-core + volumes: + - ./mailman/core:/opt/mailman/ + depends_on: + - postgresql + environment: + - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresql/${POSTGRES_MAILMAN_DATABASE} + - DATABASE_TYPE=postgres + - DATABASE_CLASS=mailman.database.postgresql.PostgreSQLDatabase + - HYPERKITTY_API_KEY=somerandomapikeythatiobviouslydidnotcreatemyself + ports: + - "8020:8001" + networks: + - gewisdb_network + mailman-web: + image: maxking/mailman-web:0.4 + container_name: mailman-web + hostname: mailman-web + depends_on: + - postgresql + volumes: + - ./mailman/web:/opt/mailman-web-data/ + environment: + - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresql/${POSTGRES_MAILMAN_DATABASE} + - DATABASE_TYPE=postgres + - HYPERKITTY_API_KEY=somerandomapikeythatiobviouslydidnotcreatemyself + - SECRET_KEY=anotherandomkeythatiobviouslydidnotcreatemyself + - SERVE_FROM_DOMAIN=localhost + - UWSGI_STATIC_MAP=/static=/opt/mailman-web-data/static + ports: + - "8021:8000" + networks: + - gewisdb_network nginx: build: docker/nginx + volumes: + - ./mailman/web/static:/var/html/mailman/ ports: - "80:9725" stripe: @@ -50,6 +88,7 @@ services: dockerfile: docker/web/development/Dockerfile context: . depends_on: + - mailman-core - postgresql volumes: diff --git a/docker/pgadmin/create-gewisdb_report-database.sh b/docker/pgadmin/create-gewisdb-database.sh similarity index 62% rename from docker/pgadmin/create-gewisdb_report-database.sh rename to docker/pgadmin/create-gewisdb-database.sh index 7ed948e3b..6275052e9 100644 --- a/docker/pgadmin/create-gewisdb_report-database.sh +++ b/docker/pgadmin/create-gewisdb-database.sh @@ -4,4 +4,6 @@ set -e psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-PGSQL CREATE DATABASE $DOCTRINE_REPORT_DATABASE; GRANT ALL PRIVILEGES ON DATABASE $DOCTRINE_REPORT_DATABASE TO $POSTGRES_USER; + CREATE DATABASE $POSTGRES_MAILMAN_DATABASE; + GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_MAILMAN_DATABASE TO $POSTGRES_USER; PGSQL From b13c82e79d7380c46d5ef5e8176aa881b206ce59 Mon Sep 17 00:00:00 2001 From: Tom Udding Date: Mon, 13 Mar 2023 21:35:50 +0100 Subject: [PATCH 2/2] [WIP] Add initial synchronisation with Mailman This allows syncronisation of mailing list ids from Mailman and they can then be added to a mailing list. At this point there is no actual synchronisation of memberships. --- .env.dist | 5 + .idea/inspectionProfiles/Project_Default.xml | 2 +- .idea/php.xml | 3 +- composer.json | 5 +- composer.lock | 73 +++++- config/autoload/local.development.php.dist | 10 + config/autoload/local.production.php.dist | 10 + config/modules.config.php | 1 + docker-compose.override.yml | 4 +- docker-compose.yml | 7 + docker/web/development/Dockerfile | 3 + docker/web/production/Dockerfile | 4 + module/Application/src/Model/ConfigItem.php | 24 +- .../src/Model/Enums/ConfigNamespaces.php | 3 +- module/Application/src/Service/Config.php | 13 +- module/Database/config/module.config.php | 59 ++++- .../Factory/MemberControllerFactory.php | 4 + .../src/Controller/MemberController.php | 10 + .../src/Controller/SettingsController.php | 77 +++++- module/Database/src/Form/MailingList.php | 25 ++ module/Database/src/Form/MemberLists.php | 70 ++++- .../Factory/MailingListMemberFactory.php | 23 ++ .../Database/src/Mapper/MailingListMember.php | 69 +++++ module/Database/src/Mapper/Member.php | 4 +- .../Database/src/Mapper/ProspectiveMember.php | 8 +- module/Database/src/Model/MailingList.php | 81 +++--- .../Database/src/Model/MailingListMember.php | 195 ++++++++++++++ module/Database/src/Model/Member.php | 66 +++-- .../Database/src/Model/ProspectiveMember.php | 37 +-- module/Database/src/Module.php | 23 ++ module/Database/src/Service/Api.php | 5 + .../Service/Factory/MailingListFactory.php | 4 + .../src/Service/Factory/MailmanFactory.php | 40 +++ .../src/Service/Factory/MemberFactory.php | 8 + module/Database/src/Service/MailingList.php | 39 ++- module/Database/src/Service/Mailman.php | 241 ++++++++++++++++++ module/Database/src/Service/Member.php | 92 +++++-- .../database/email/member-registration.phtml | 4 +- .../view/database/member/mailman.phtml | 15 ++ .../Database/view/database/member/show.phtml | 2 +- .../database/prospective-member/show.phtml | 4 +- .../settings/{list.phtml => add-list.phtml} | 72 +++--- .../view/database/settings/delete-list.phtml | 2 +- .../view/database/settings/index.phtml | 2 +- .../view/database/settings/lists.phtml | 70 +++++ .../src/Listener/DatabaseUpdateListener.php | 5 + module/Report/src/Model/MailingList.php | 98 +------ module/Report/src/Model/MailingListMember.php | 187 ++++++++++++++ module/Report/src/Model/Member.php | 64 ++--- .../src/Service/Factory/MiscFactory.php | 4 + module/Report/src/Service/Member.php | 8 +- module/Report/src/Service/Misc.php | 50 +++- phpcs.xml.dist | 2 + 53 files changed, 1586 insertions(+), 350 deletions(-) create mode 100644 module/Database/src/Mapper/Factory/MailingListMemberFactory.php create mode 100644 module/Database/src/Mapper/MailingListMember.php create mode 100644 module/Database/src/Model/MailingListMember.php create mode 100644 module/Database/src/Service/Factory/MailmanFactory.php create mode 100644 module/Database/src/Service/Mailman.php create mode 100644 module/Database/view/database/member/mailman.phtml rename module/Database/view/database/settings/{list.phtml => add-list.phtml} (65%) create mode 100644 module/Database/view/database/settings/lists.phtml create mode 100644 module/Report/src/Model/MailingListMember.php diff --git a/.env.dist b/.env.dist index 29bbfa6a0..5c2ee1954 100644 --- a/.env.dist +++ b/.env.dist @@ -55,6 +55,11 @@ MAIL_TO_SUBSCRIPTION_NAME='Secretary of GEWIS' MAIL_FROM_SECRETARY_ADDRESS=example@example.com MAIL_FROM_SECRETARY_NAME='Secretary of GEWIS' +MAILMAN_API_ENDPOINT=http://mailmanc:8001/3.1/ +MAILMAN_API_VERSION='3.1' +MAILMAN_API_USERNAME=restadmin +MAILMAN_API_PASSWORD=restpass + # LDAP settings (fill in to enable LDAP) LDAP_SERVERS=ldaps.gewis.nl LDAP_STARTTLS=true diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index ff8882fb2..65d8763a1 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -11,7 +11,7 @@ - +