{"record":{"id":"ee157cfa94a4793e","repo":"gitroomhq/postiz-app","slug":"this-post-was-already-published-on-dayjs-utc","errorCode":null,"errorMessage":"This post was already published on ${dayjs\n  .utc(post.publishDate)\n  .format('YYYY-MM-DD HH:mm')} UTC. Saving it this way would publish it again to ${\n  post.integration?.providerIdentifier || 'the channel'\n}. To edit without republishing, ${howToUpdate}. To intentionally publish again, pass republish: true.","messagePattern":"This post was already published on (.+?) UTC\\. Saving it this way would publish it again to (.+?)\\. To edit without republishing, (.+?)\\. To intentionally publish again, pass republish: true\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts","lineNumber":891,"sourceCode":"    }\n    return '';\n  }\n\n  // A schedule-type save targeting an already-PUBLISHED post republishes it to\n  // the platform: require the explicit `republish` opt-in instead. The message\n  // doubles as the confirmation dialog for API/MCP automation.\n  private guardAgainstRepublish(\n    post: { state: State; publishDate: Date; integration?: { providerIdentifier: string } } | null,\n    source: 'createPost' | 'changeDate'\n  ) {\n    if (post?.state !== 'PUBLISHED') {\n      return;\n    }\n\n    const howToUpdate =\n      source === 'createPost' ? `use type 'update'` : `use action 'update'`;\n\n    throw new BadRequestException(\n      `This post was already published on ${dayjs\n        .utc(post.publishDate)\n        .format('YYYY-MM-DD HH:mm')} UTC. Saving it this way would publish it again to ${\n        post.integration?.providerIdentifier || 'the channel'\n      }. To edit without republishing, ${howToUpdate}. To intentionally publish again, pass republish: true.`\n    );\n  }\n\n  async createPost(\n    orgId: string,\n    body: CreatePostDto,\n    creationMethod: CreationMethod,\n    keepGroup = false\n  ): Promise<any[]> {\n    const postList = [];\n    for (const post of body.posts) {\n      if (\n        (body.type === 'schedule' || body.type === 'now') &&","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts#L873-L909","documentation":"Guard against accidental republication: saving a post whose state is already PUBLISHED through the create/normal save path would push it to the channel again. The error tells you to either use the update flow (type 'update' / action 'update') or explicitly opt in with republish: true.","triggerScenarios":"Calling createPost (or an equivalent save) with the id of a post whose state is PUBLISHED, without republish: true; e.g. a calendar UI re-saving an already-sent post.","commonSituations":"Retry logic resubmitting an already-succeeded create; editing UI defaulting to create mode for existing published posts; double-click submissions; API consumers unaware the post already went out.","solutions":["Switch the request to the update flow: set type: 'update' (or action: 'update') in the payload","If a genuine republication is intended, pass republish: true in the body","Debounce/disable the save button to prevent duplicate submissions","Check the post's state via getPostById before saving and route published posts to the editor"],"exampleFix":"// before\nawait createPost(orgId, { ...body, posts: body.posts }); // post already PUBLISHED\n// after\nawait createPost(orgId, { ...body, type: 'update', posts: body.posts });\n// or intentional repost:\nawait createPost(orgId, { ...body, republish: true, posts: body.posts });","handlingStrategy":"validation","validationCode":"const post = await getPostById(orgId, postId);\nconst isPublished = post?.state === 'PUBLISHED';\nawait createPost(orgId, { ...body, ...(isPublished && !intendedRepublish ? { type: 'update' } : {}), republish: intendedRepublish || undefined });","typeGuard":null,"tryCatchPattern":"try {\n  await createPost(orgId, body);\n} catch (e) {\n  if (/already published/.test(String(e?.response?.message ?? e))) {\n    await createPost(orgId, { ...body, type: 'update' });\n  } else throw e;\n}","preventionTips":["Check post state before saving; route PUBLISHED posts to the update flow","Debounce submit buttons to avoid double-post attempts","Only pass republish: true when the user explicitly confirmed republication"],"tags":["posts","published","republish","guard","validation"],"backgroundTag":"duplicate-submission-guard","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}