mealie icon indicating copy to clipboard operation
mealie copied to clipboard

[BUG] - Mealplan webhook payload includes all mealplan items, regardless of date

Open bennettmsherman opened this issue 6 months ago • 3 comments

First Check

  • [X] This is not a feature request.
  • [X] I added a very descriptive title to this issue (title field is above this).
  • [X] I used the GitHub search to find a similar issue and didn't find it.
  • [X] I searched the Mealie documentation, with the integrated search.
  • [X] I already read the docs and didn't find an answer.
  • [ ] This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

I spun up n8n to test out Mealie's webhook integration. Ultimately my goal is to send daily emails with the mealplan contents for the day.

The webhook config page in mealie says:

The webhooks defined below will be executed when a meal is defined for the day. At the scheduled time the webhooks will be sent with the data from the recipe that is scheduled for the day.

In practice, I'm seeing mealplan items in the webhook body for the current day, but also past and future.

Steps to Reproduce

  • Add an item to the mealplan for a prior day, current day, and future day.
  • Add webhook
  • Click "test" button - webhook payload includes all 3 recipes
  • Wait for scheduled run - webook payload includes all 3 recipes

Please provide relevant logs

Sample payload when using test button:

[
  {
    "headers": {
      "host": "n8n.mysite.com",
      "user-agent": "python-requests/2.32.3",
      "content-length": "1091",
      "accept": "*/*",
      "accept-encoding": "gzip, deflate",
      "content-type": "application/json",
      "true-client-ip": "172.16.0.90",
      "x-forwarded-for": "172.16.0.90",
      "x-forwarded-host": "n8n.mysite.com",
      "x-forwarded-proto": "https",
      "x-real-ip": "172.16.0.90"
    },
    "params": {},
    "query": {},
    "body": {
      "message": {
        "title": "Webhook Task",
        "body": "Test Webhook"
      },
      "eventType": 2,
      "integrationId": "mealie_generic_user",
      "documentData": {
        "documentType": "mealplan",
        "operation": "info",
        "webhookStartDt": "0001-01-01T00:00:00Z",
        "webhookEndDt": "0001-01-01T00:00:00Z",
        "webhookBody": [
          {
            "date": "2025-01-01",
            "entryType": "dinner",
            "title": "Future test meal",
            "text": "",
            "recipeId": null,
            "id": 3,
            "groupId": "e40f4f8f-5d55-4460-9b32-604c13dd32bc",
            "userId": "26f8118a-c1c2-4b7c-aee3-a4acdeca9d86",
            "recipe": null
          },
          {
            "date": "2024-01-01",
            "entryType": "breakfast",
            "title": "Test meal",
            "text": "For testing webhooks",
            "recipeId": null,
            "id": 2,
            "groupId": "e40f4f8f-5d55-4460-9b32-604c13dd32bc",
            "userId": "26f8118a-c1c2-4b7c-aee3-a4acdeca9d86",
            "recipe": null
          },
          {
            "date": "2024-08-18",
            "entryType": "dinner",
            "title": "Pasta w/ sausage",
            "text": "",
            "recipeId": null,
            "id": 1,
            "groupId": "e40f4f8f-5d55-4460-9b32-604c13dd32bc",
            "userId": "26f8118a-c1c2-4b7c-aee3-a4acdeca9d86",
            "recipe": null
          }
        ]
      },
      "eventId": "0be7e432-9832-4768-ab05-30f2b9551512",
      "timestamp": "2024-08-18T17:22:14.271867Z"
    },
    "webhookUrl": "https://n8n.mysite.com/webhook/...",
    "executionMode": "production"
  }
]

Sample payload from a scheduled run:

[
  {
    "headers": {
      "host": "n8n.mysite.com",
      "user-agent": "python-requests/2.32.3",
      "content-length": "1100",
      "accept": "*/*",
      "accept-encoding": "gzip, deflate",
      "content-type": "application/json",
      "true-client-ip": "172.16.0.90",
      "x-forwarded-for": "172.16.0.90",
      "x-forwarded-host": "n8n.mysite.com",
      "x-forwarded-proto": "https",
      "x-real-ip": "172.16.0.90"
    },
    "params": {},
    "query": {},
    "body": {
      "message": {
        "title": "Webhook Task",
        "body": "generic"
      },
      "eventType": 2,
      "integrationId": "mealie_generic_user",
      "documentData": {
        "documentType": "mealplan",
        "operation": "info",
        "webhookStartDt": "2024-08-18T17:21:25.803532Z",
        "webhookEndDt": "2024-08-18T17:26:25.872743Z",
        "webhookBody": [
          {
            "date": "2025-01-01",
            "entryType": "dinner",
            "title": "Future test meal",
            "text": "",
            "recipeId": null,
            "id": 3,
            "groupId": "e40f4f8f-5d55-4460-9b32-604c13dd32bc",
            "userId": "26f8118a-c1c2-4b7c-aee3-a4acdeca9d86",
            "recipe": null
          },
          {
            "date": "2024-01-01",
            "entryType": "breakfast",
            "title": "Test meal",
            "text": "For testing webhooks",
            "recipeId": null,
            "id": 2,
            "groupId": "e40f4f8f-5d55-4460-9b32-604c13dd32bc",
            "userId": "26f8118a-c1c2-4b7c-aee3-a4acdeca9d86",
            "recipe": null
          },
          {
            "date": "2024-08-18",
            "entryType": "dinner",
            "title": "Pasta w/ sausage",
            "text": "",
            "recipeId": null,
            "id": 1,
            "groupId": "e40f4f8f-5d55-4460-9b32-604c13dd32bc",
            "userId": "26f8118a-c1c2-4b7c-aee3-a4acdeca9d86",
            "recipe": null
          }
        ]
      },
      "eventId": "fe533696-fc8b-4445-9b3b-446810e93243",
      "timestamp": "2024-08-18T17:26:25.927366Z"
    },
    "webhookUrl": "https://n8n.mysite.com/webhook/......",
    "executionMode": "production"
  }
]

Mealie Version

v1.11.0 - a41ad8c6ed968b43e5674ce77785dbdf76f77f57

Deployment

Docker (Linux)

Additional Deployment Details

No response

bennettmsherman avatar Aug 18 '24 17:08 bennettmsherman