Skip to content

Commit

Permalink
doc: Add instructions for setting up Firestore TTL policies for deliv…
Browse files Browse the repository at this point in the history
…ery.expireAt field
  • Loading branch information
Gustolandia authored and cabljac committed Jan 6, 2025
1 parent ed34bd6 commit e3e4c3c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions firestore-send-email/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.1.35

docs - Added instructions for setting up Firestore TTL policies for the `delivery.expireAt` field.

## Version 0.1.34

fixed - SendGrid v3 issues (#2020)
Expand Down
11 changes: 11 additions & 0 deletions firestore-send-email/POSTINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ admin
.then(() => console.log("Queued email for delivery!"));
```
#### **Automatic Deletion of Email Documents**
The `delivery.expireAt` field is automatically populated by the extension if TTL is enabled. To ensure expired email documents are deleted:
1. Confirm that Firestore TTL is enabled in the extension's `.env` file:
```
TTL_EXPIRE_TYPE=minutes
TTL_EXPIRE_VALUE=2
```
2. Configure a Firestore TTL policy targeting the `delivery.expireAt` field (as described in the README).
### Using this extension
See the [official documentation](https://firebase.google.com/docs/extensions/official/firestore-send-email) for information on using this extension, including advanced use cases such as using Handlebars templates and managing email delivery status.
Expand Down
3 changes: 3 additions & 0 deletions firestore-send-email/PREINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ To use your Outlook/Hotmail email account with this extension, you'll need to ha

Before installing this extension, make sure that you've [set up a Cloud Firestore database](https://firebase.google.com/docs/firestore/quickstart) in your Firebase project.

#### **Prerequisites for TTL Deletion**
If you intend to use TTL deletion, ensure your Firestore database supports TTL policies. This requires project permissions to enable and configure Firestore TTL policies for the `delivery.expireAt` field.

#### Billing
To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing)

Expand Down
3 changes: 3 additions & 0 deletions firestore-send-email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ To use your Outlook/Hotmail email account with this extension, you'll need to ha

Before installing this extension, make sure that you've [set up a Cloud Firestore database](https://firebase.google.com/docs/firestore/quickstart) in your Firebase project.

#### **Prerequisites for TTL Deletion**
If you intend to use TTL deletion, ensure your Firestore database supports TTL policies. This requires project permissions to enable and configure Firestore TTL policies for the `delivery.expireAt` field.

#### Billing
To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing)

Expand Down
2 changes: 1 addition & 1 deletion firestore-send-email/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: firestore-send-email
version: 0.1.34
version: 0.1.35
specVersion: v1beta

displayName: Trigger Email from Firestore
Expand Down
4 changes: 4 additions & 0 deletions firestore-send-email/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function getExpireAt(startTime: admin.firestore.Timestamp) {
const now = startTime.toDate();
const value = config.TTLExpireValue;
switch (config.TTLExpireType) {
case "minute":
case "minutes": // Add this to support plural
now.setMinutes(now.getMinutes() + value);
break;
case "hour":
now.setHours(now.getHours() + value);
break;
Expand Down

0 comments on commit e3e4c3c

Please sign in to comment.