From 0d02b727eefecda37226b0d08ce387ab867d115e Mon Sep 17 00:00:00 2001
From: Gregor Schulz <gregor.schulz@holi.social>
Date: Thu, 29 Aug 2024 13:04:02 +0000
Subject: [PATCH] add moderation project

---
 .envrc.local.backends.template |  1 +
 README.md                      |  5 ++++-
 init.sh                        |  2 ++
 mprocs-local-backend.yaml      | 17 +++++++++++++++++
 pubsub/init.py                 |  6 +++---
 5 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/.envrc.local.backends.template b/.envrc.local.backends.template
index 3888ba6..0ae4468 100644
--- a/.envrc.local.backends.template
+++ b/.envrc.local.backends.template
@@ -10,3 +10,4 @@ export LOCAL_BACKEND_STORYBOOK=true
 export LOCAL_BACKEND_NOTIFICATIONS=false
 export LOCAL_BACKEND_TRANSLATION=false
 export LOCAL_BACKEND_LIBRETRANSLATE=false
+export LOCAL_MODERATION=false
diff --git a/README.md b/README.md
index 18fe76f..334f685 100644
--- a/README.md
+++ b/README.md
@@ -277,7 +277,7 @@ forall-git git pull # pull all repositories
 The following table lists all ports that are used for local execution.
 
 | Application                     | Port |
-| ------------------------------- | ---- |
+|---------------------------------|------|
 | oathkeeper                      | 4455 |
 | unified-api                     | 4000 |
 | chat-server (matrix client)     | 8008 |
@@ -303,6 +303,9 @@ The following table lists all ports that are used for local execution.
 | meet (auth)                     | 9301 |
 | translation-api                 | 8089 |
 | libretranslate                  | 5000 |
+| moderation ui (backoffice)      | 5173 |  
+| moderation backend              | 3001 |  
+| moderation federator            | 8080 |  
 
 ## Terraform authentication (optional)
 
diff --git a/init.sh b/init.sh
index 47a6e4b..b19f60e 100755
--- a/init.sh
+++ b/init.sh
@@ -128,10 +128,12 @@ checkoutAndPrepare git@gitlab.holi.team:app/holi-ocis-integration.git holi-ocis-
 checkoutAndPrepare git@gitlab.holi.team:app/holi-chat-integration.git holi-chat-integration
 checkoutAndPrepare git@gitlab.holi.team:app/holi-libretranslate.git holi-libretranslate
 checkoutAndPrepare git@gitlab.holi.team:app/holi-translation-api.git holi-translation-api
+checkoutAndPrepare git@gitlab.holi.team:app/holi-moderation.git holi-moderation
 
 # former repositories that shall be deleted
 rm -rf holi-tracking-endpoint # added 2024/07/12, can be removed pretty safely end of 2024
 
+
 # these are technically not used in a local development environment, but they
 # make use of common definitions from holi-meta. If you want to check them out,
 # then use `./init.sh full`
diff --git a/mprocs-local-backend.yaml b/mprocs-local-backend.yaml
index 6fcf99f..7964a74 100644
--- a/mprocs-local-backend.yaml
+++ b/mprocs-local-backend.yaml
@@ -186,3 +186,20 @@ procs:
       send-keys:
         - <C-c>
         - <C-c>
+  moderation:
+    cwd: <CONFIG_DIR>/holi-moderation
+    env:
+      DEV_ENV: local
+    shell: >
+      corepack yarn install;
+      if [ "$LOCAL_MODERATION" = "true" ]; then
+        corepack yarn start
+      else
+        echo starting fake;
+        corepack yarn build;
+        corepack yarn start-fake;
+      fi;
+    stop:
+      send-keys:
+        - <C-c>
+        - <C-c>
diff --git a/pubsub/init.py b/pubsub/init.py
index 6d744ea..852fd55 100644
--- a/pubsub/init.py
+++ b/pubsub/init.py
@@ -15,12 +15,13 @@ if ocis_enabled:
 if chat_enabled:
     print("Adding CHAT subscription")
     subscribers.append(['chat', 8088])
+
 publisher = pubsub_v1.PublisherClient()
 
-for topic_name in topic_names:    
+for topic_name in topic_names:
     topic_path = publisher.topic_path(PUBSUB_PROJECT_ID, topic_name)
     topic = publisher.create_topic(request={"name": topic_path})
-    subscriber = pubsub_v1.SubscriberClient()    
+    subscriber = pubsub_v1.SubscriberClient()
     print(f"Topic: {topic.name}")
 
     for sub in subscribers:
@@ -37,4 +38,3 @@ for topic_name in topic_names:
 
         print(f"Push subscription: {subscription.name}")
         print(f"Subscription endpoint: {subscription.push_config.push_endpoint}")
-   
\ No newline at end of file
-- 
GitLab