这是indexloc提供的服务,不要输入任何密码
Skip to content

Cloud Function for Publishing Documents to Public Collection #382

@DennisAlund

Description

@DennisAlund

Description

Implement a Cloud Function that handles the publication status of a document. When a document's status changes to "published", its data should be copied to a public collection and its associated files in Cloud Storage should be copied to a public directory. If the document's status changes from "published" to "unpublished", the document should be removed from the public collection and its associated files should be deleted.

Requirements

  1. Publish Document:

    • If the document's previous status was not "published" and the new status is "published":
      • Copy the document data to the collection tanam-public with the same document ID.
      • Copy all files in Cloud Storage under the path /tanam-documents/{id}/** to /tanam-public/{id}/**.
  2. Unpublish Document:

    • If the document's previous status was "published" and the new status is not "published":
      • Remove the document with the same ID from the collection tanam-public.
      • Delete the folder /tanam-public/{id}/ in Cloud Storage.

Steps to Accomplish

  1. Create Cloud Function:

    • Create a Cloud Function that triggers on document update in the Firestore collection.
    • Check the document's publishedAt attribute to determine the status change.
  2. Handle Publish Status:

    • If the document's previous status was not "published" and the new status is "published":
      • Copy the document data to tanam-public collection.
      • Copy associated files from /tanam-documents/{id}/** to /tanam-public/{id}/**.
  3. Handle Unpublish Status:

    • If the document's previous status was "published" and the new status is not "published":
      • Remove the document from the tanam-public collection.
      • Delete the folder /tanam-public/{id}/ in Cloud Storage.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions