-
Notifications
You must be signed in to change notification settings - Fork 41
Labels
platform:backendBackend / cloud functionsBackend / cloud functionspriority:medium 👍Regular priority issueRegular priority issue
Milestone
Description
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
-
Publish Document:
- If the document's previous status was not "published" and the new status is "published":
- Copy the document
data
to the collectiontanam-public
with the same document ID. - Copy all files in Cloud Storage under the path
/tanam-documents/{id}/**
to/tanam-public/{id}/**
.
- Copy the document
- If the document's previous status was not "published" and the new status is "published":
-
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.
- Remove the document with the same ID from the collection
- If the document's previous status was "published" and the new status is not "published":
Steps to Accomplish
-
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.
-
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}/**
.
- Copy the document data to
- If the document's previous status was not "published" and the new status is "published":
-
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.
- Remove the document from the
- If the document's previous status was "published" and the new status is not "published":
Metadata
Metadata
Assignees
Labels
platform:backendBackend / cloud functionsBackend / cloud functionspriority:medium 👍Regular priority issueRegular priority issue
Type
Projects
Status
Done