indiekit icon indicating copy to clipboard operation
indiekit copied to clipboard

Duplication prevention

Open gerwitz opened this issue 1 year ago • 2 comments

Is your feature request related to a problem?

I use a client (the iOS/macOS Drafts app with a custom script) to send Micropub posts to Indiekit. It's too easy for me to accidentally send more than one, which results in me scrambling to stop Indiekit before it syndicates and clean up my git repo.

Describe the solution you’d like

Reject posts that exactly match existing posts, aside from time.

Describe alternatives you’ve considered

Being more careful.

Additional context

No response

gerwitz avatar Apr 04 '24 08:04 gerwitz

I think there might be 2 issues at play here. You’re using the {slug} path token and that’ll create new randomly generated 5-character slug if no mp-slug or name property is provided.

The second is that maybe in this case, an update action should be performed instead.

Quickly looking into how things stand at the moment, I think there might be untold issues converting a create action item with the same properties into an update action (not impossible but… icky).

I wonder however… all the tokens used are based on post property values (typically published); this means they won’t change unless the source properties change. However, falling back to a randomly generated sequence breaks this convention, and can cause issues like this.

What do you think to this idea: change it so that {slug} falls back to, not to 5 randomly generated characters, but the first 7 digits of a MD5/SHA1 generated hash from the published value? This would mean successive saves of the same file (with the same published date and same name) would be written to the same file. Would that fix this issue? (I should probably make this change anyway…)

paulrobertlloyd avatar Apr 04 '24 15:04 paulrobertlloyd

Hmmm, so each new create action has an updated published date (of course), so the above suggestion makes no difference.

Back to the drawing board…

paulrobertlloyd avatar Apr 06 '24 22:04 paulrobertlloyd