Commit Graph

18 Commits

Author SHA1 Message Date
d5a366c4f2 feat(config): update n8n webhook handling (#366)
Some checks failed
Build Docker / Create Docker Image (release) Failing after 4m0s
Release / Tag release (push) Successful in 37s
Release / Create Release (push) Successful in 7s
Release / Publish Docker Images (push) Failing after 2m57s
Snyk / security (push) Successful in 8m22s
Okay, I will explain the code changes presented in the diff.  The primary focus of this pull request appears to be refactoring the N8N webhook URL configuration to use separate URLs for GET and POST requests. Additionally, several files in the `.github` directory have been moved to an `.archive/.github` directory.

**1. Directory Changes:**

*   A number of files related to GitHub configuration (CODEOWNERS, issue templates, dependabot configuration, renovate configuration, and workflow files) have been moved from the `.github` directory to `.archive/.github`. This suggests that these configurations are no longer actively used or are being superseded by other configurations.

**2. Environment Variable Changes (.env.default):**

```diff
--- a/.env.default
+++ b/.env.default
@@ -5,5 +5,6 @@
  APPROVED_DOMAINS="example.com,hello.com"
  APPROVED_ROOMS="abc123,def456"
  APPROVED_USERS="bob@example.com,john@me.com"
  BOT_NAME=""
 -N8N_WEBHOOK_URL=""
 +N8N_GET_WEBHOOK_URL=""
 +N8N_POST_WEBHOOK_URL=""
  WEBEX_API_KEY=""
```

*   The `.env.default` file, which provides default values for environment variables, has been modified.
*   The single `N8N_WEBHOOK_URL` environment variable has been removed.
*   Two new environment variables, `N8N_GET_WEBHOOK_URL` and `N8N_POST_WEBHOOK_URL`, have been added. This indicates the application now requires separate webhook URLs for GET and POST requests to the N8N service.

**3. Configuration Class Changes (app/utils/config.py):**

```diff
--- a/app/utils/config.py
+++ b/app/utils/config.py
@@ -42,9 +42,14 @@ class Config:
          return os.environ["ADMIN_EMAIL"].split(",")

      @property
-    def n8n_webhook_url(self) -> str:
-        """Returns the n8n webhook URL."""
-        return os.environ["N8N_WEBHOOK_URL"]
+    def n8n_get_webhook_url(self) -> str:
+        """Returns the n8n GET webhook URL."""
+        return os.environ["N8N_GET_WEBHOOK_URL"]
+
+    @property
+    def n8n_post_webhook_url(self) -> str:
+        """Returns the n8n POST webhook URL."""
+        return os.environ["N8N_POST_WEBHOOK_URL"]

      @property
      def approved_users(self) -> list:
```

*   The `Config` class in `app/utils/config.py` has been updated to reflect the environment variable changes.
*   The `n8n_webhook_url` property has been removed.
*   Two new properties, `n8n_get_webhook_url` and `n8n_post_webhook_url`, have been added.  These properties retrieve the corresponding environment variables and provide access to the individual webhook URLs.

**4. N8N Utility Changes (app/utils/n8n.py):**

```diff
--- a/app/utils/n8n.py
+++ b/app/utils/n8n.py
@@ -16,7 +16,7 @@ def __n8n_post(data: dict) -> bool:
      """
      headers: dict = {"Content-Type": "application/json"}
      resp: requests.Response = requests.post(
-        url=config.n8n_webhook_url,
+        url=config.n8n_post_webhook_url,
          headers=headers,
          json=data,
          timeout=10,
@@ -58,7 +58,7 @@ def get_tasks(requestor) -> bool:
      """
      headers: dict = {"Content-Type": "application/json"}
      resp: requests.Response = requests.get(
-        url=config.n8n_webhook_url,
+        url=config.n8n_get_webhook_url,
          headers=headers,
          timeout=10,
          verify=True,
```

*   The `app/utils/n8n.py` file has been modified to use the new configuration properties.
*   In the `__n8n_post` function, the `url` parameter in the `requests.post` call now uses `config.n8n_post_webhook_url` instead of the old `config.n8n_webhook_url`.
*   Similarly, in the `get_tasks` function, the `url` parameter in the `requests.get` call now uses `config.n8n_get_webhook_url`.

**5. Test Changes (tests/test\_config\_1.py and tests/test\_config\_2.py):**

```diff
--- a/tests/test_config_1.py
+++ b/tests/test_config_1.py
@@ -16,7 +16,8 @@ def test_config() -> None:
          "WEBEX_API_KEY": "testing",
          "ADMIN_FIRST_NAME": "Test",
          "ADMIN_EMAIL": "test@test.com",
-        "N8N_WEBHOOK_URL": "https://n8n.test.com/webhook/abcdefg",
+        "N8N_GET_WEBHOOK_URL": "https://n8n.test.com/webhook/abc",
+        "N8N_POST_WEBHOOK_URL": "https://n8n.test.com/webhook/def",
          "APPROVED_USERS": "test@test.com",
          "APPROVED_DOMAINS": "test.com",
          "APPROVED_ROOMS": "test",
@@ -34,7 +35,8 @@ def test_config() -> None:
      assert config.approved_rooms == config_vars["APPROVED_ROOMS"].split(",")
      assert config.approved_users == config_vars["APPROVED_USERS"].split(",")
      assert config.bot_name == config_vars["BOT_NAME"]
-    assert config.n8n_webhook_url == config_vars["N8N_WEBHOOK_URL"]
+    assert config.n8n_get_webhook_url == config_vars["N8N_GET_WEBHOOK_URL"]
+    assert config.n8n_post_webhook_url == config_vars["N8N_POST_WEBHOOK_URL"]
      assert config.version == config_vars["APP_VERSION"]
      assert config.webex_token == config_vars["WEBEX_API_KEY"]
```

*   The test files have been updated to use the new environment variables and configuration properties.  The old `N8N_WEBHOOK_URL` is removed and `N8N_GET_WEBHOOK_URL` and `N8N_POST_WEBHOOK_URL` are added and asserted.

**Summary:**

This pull request introduces a separation of N8N webhook URLs for GET and POST requests. This likely allows for more specific control and potentially different workflows depending on the HTTP method used to interact with the N8N service. The `.github` directory changes suggest cleaning up the repository by archiving old or unused configuration files. The tests are updated to align with the new configuration structure.

Co-authored-by: Luke Tainton <ltainton@cisco.com>
Reviewed-on: #366
2025-08-04 09:59:52 +02:00
0da568d5eb chore(ci): remove Sonar (#355)
Some checks failed
Release / Tag release (push) Successful in 35s
Release / Create Release (push) Successful in 9s
Release / Publish Docker Images (push) Failing after 2m41s
Snyk / security (push) Successful in 2m15s
Reviewed-on: #355
2025-05-31 13:08:47 +02:00
fa9ea8eafb chore(deps): lock file maintenance (#348)
All checks were successful
Snyk / security (push) Successful in 2m7s
This PR contains the following updates:

| Update | Change |
|---|---|
| lockFileMaintenance | All locks refreshed |

🔧 This Pull Request updates lock files to use the latest dependency versions.

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on monday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNjEuNCIsInVwZGF0ZWRJblZlciI6IjM5LjI2MS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==-->

Co-authored-by: Luke Tainton <luke@tainton.uk>
Reviewed-on: #348
Co-authored-by: Renovate [BOT] <renovate-bot@git.tainton.uk>
Co-committed-by: Renovate [BOT] <renovate-bot@git.tainton.uk>
2025-05-07 01:42:51 +02:00
b11cc26daa fix(config): always return a list, even if empty, as required by webex_bot 2024-11-24 10:41:08 +00:00
5efa42d35d feat(sentry): remove Sentry 2024-11-24 10:20:04 +00:00
2d4a1294cb fix(sentry): only import/run Sentry if enabled 2024-11-24 10:08:15 +00:00
f611b685b3 fix(config): return None if env var is empty or non-existent (#315)
* fix(config): return None if env var is empty or non-existent
* chore: fix pylint issues
* fix: add unit test for non-existent env vars
2024-11-21 22:26:07 +00:00
b758d0dfda feat(security): add approved rooms/users/domains as env variables (#277)
* feat(security): add approved rooms/users/domains as env variables
* chore(lint): fix R0902
* chore(lint): fix C0114
* chore(lint): fix C0116
* chore(lint): fix C0413
2024-08-30 19:38:56 +01:00
6c1c5edf04 chore: add pre-commit 2024-08-04 18:50:53 +01:00
61144056ae Add release to Sentry SDK 2024-04-21 16:56:27 +01:00
a4007d585b Auto-inject version into image 2024-04-21 16:52:55 +01:00
123ed8aa15 Add APM (#184)
* Add APM
* Fix unit tests
* Remove apm.py
* Add SonarCloud recommendations
* SonarCloud python:S6890
2024-04-21 16:17:00 +01:00
Luke Tainton
e3c63b3ded Change 'My Tasks' to 'My Submitted Tasks' 2023-06-30 14:08:38 +01:00
de0583d6c9 Update tokens, formatting (#43) 2023-06-04 10:24:27 +01:00
202d502d22 Specify only to use text (#37) 2023-05-08 18:16:43 +01:00
8eafc402ac Add 'My Tasks' button (#23) 2023-04-20 19:37:01 +01:00
Luke Tainton (ltainton)
102b74e90a Initial 2023-04-05 20:57:31 +01:00
be6546e4cc Initial commit 2023-04-05 20:02:13 +01:00