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: Option to automatically create share links for recipes in recipe actions #4676

Open
wants to merge 2 commits into
base: mealie-next
Choose a base branch
from

Conversation

ianp1
Copy link

@ianp1 ianp1 commented Dec 3, 2024

What type of PR is this?

  • feature
  • bug

What this PR does / why we need it:

Currently, when using a recipe action on a recipe that is not publicly available (due to recipe, group or household being private), the receiving service will not be able to read the recipe data.

As discussed in #4619, this PR implements an additional template option for recipe actions. The option ${share-link-expires-seconds-<x>} is automatically replaced by a newly created share link that expires after x seconds. This makes share links usable even on private recipes, groups and households.

Which issue(s) this PR fixes:

Fixes #4619

Special notes for your reviewer:

I am not completely certain, if the method to obtain the group slug is correct. Please check this part thoroughly.
Also, i have not yet created documentation for the new option - is the website documentation part of this repository?

Testing

I created a private recipe, a public recipe and multipe recipe actions

  • One containing a single share link template
  • One containing multiple share link templates with different expiry times
  • And one containing multiple share link templates, some of which having the same expiry times

I also tested with different privacy settings in group and household. The receiver of the given action was always able to read the recipes, without being logged in using the share link.

Copy link
Contributor

This PR is stale because it has been open 45 days with no activity.

Copy link
Collaborator

@michael-genson michael-genson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Sorry for taking so long on this, holidays beat me up. One change to remove an API call and we're all set.

Would you also be able to add this to the docs? Just add it to the list of merge fields and a short (one sentence) description. And then also maybe change the Bring example to use the new field (instead of url).
https://docs.mealie.io/documentation/getting-started/features/#recipe-actions

/* eslint-disable no-template-curly-in-string */
const shareLinkRegex = /\$\{share-link-expires-seconds-[0-9]+\}/g;
const group = (await api.groups.getOne(recipe.groupId || "")).data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to grab the slug from the URL instead of fetching it via the API:

import { useRoute } from "@nuxtjs/composition-api";

// put this right under "useUserApi"
const route = useRoute();

// replace the API call with this
const groupSlug = route.value.params.groupSlug || recipe.groupId || "";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Recipe actions link to homepage for private recipes
2 participants