-
Notifications
You must be signed in to change notification settings - Fork 0
Events and Triggers
The Event system we implement is based around a collection of event documents. The idea roughly is:
- When something happens we create a new Event document (user votes, writes a message, a proposal is accepted)
- When we need to do something after something happened (send a notification, send an email, update something) we implement that as. trigger on the Events collection, so it is nicely separated.
-
createdAtthe data the event occurred -
typethe type of the proposal (see below) -
objectIdthe id of the (main) object that this event pertains to (like a proposalId) - what kind of id this is is determined by the type of the event -
userIdThe id of the user that created or triggered this event (if relevant)
-
for the actual list being used in the code, see the definition of EVENT_TYPES here: https://github.com/daostack/common-firebase/blob/dev/functions/src/event/event.ts#L9
-
Product specs are on notion, here: https://www.notion.so/Emails-Notifications-Feed-654df20f7f73425da0096c070717ebf6
-
CARD_CREATION_FAILED -
COMMON_CREATED -
COMMON_CREATION_FAILED -
COMMON_WHITELISTED -
COMMON_MEMBER_ADDED -
COMMON_MEMBER_REMOVED -
FUNDING_REQUEST_CREATED -
FUNDING_REQUEST_ACCEPTED -
FUNDING_REQUEST_EXECUTED -
FUNDING_REQUEST_REJECTED -
FUNDING_REQUEST_ACCEPTED_INSUFFICIENT_FUNDS -
VOTE_CREATED- new vote was created in the votes collection -
MEMBERSHIP_REVOKED- the user membership has been revoked and the user has been removed from the common -
PAYMENT_CREATED- new payment was created -
PAYMENT_CONFIRMED- the payment can be considered done -
PAYMENT_PAID- the payment was successful. Final payment state -
PAYMENT_FAILED- the payment has failed. Final payment state -
POST_CREATED -
MESSAGE_CREATED- a message in a discussion -
REQUEST_TO_JOIN_CREATED- a request to join proposal was created -
REQUEST_TO_JOIN_ACCEPTED- a request to join proposal was accepted (but not executed yet - in particular, not paid yet) -
REQUEST_TO_JOIN_EXECUTED- a request to join was approved, paid and the user is a member now -
REQUEST_TO_JOIN_REJECTED -
SUBSCRIPTION_CREATED- subscription was created for approved join proposal in monthly common -
SUBSCRIPTION_PAYMENT_CREATED- new monthly subscription payment was made -
SUBSCRIPTION_PAYMENT_FAILED- the monthly subscription payment has failed -
SUBSCRIPTION_CANCELED_BY_USER- the user has canceled his/hers subscription. The membership will be revoked on the next due date -
SUBSCRIPTION_CANCELED_BY_PAYMENT_FAILURE- the user’s subscription has been canceled and her membership revoked because the payment failed multiple times -
APPROVED_PROPOSAL- a proposal was approved (but not yet executed w)
| Event name | userFilter | Notification | Description | |
|---|---|---|---|---|
COMMON_CREATED |
common creator | X | admin: adminCommonCreated, user: userCommonCreated
|
When a user creates a common, inform creator and admin |
COMMON_CREATION_FAILED |
common creator | X | X | When the common creation failed |
COMMON_WHITELISTED |
all users in the DB, excluding the common creator | A new Common was just featured! |
user: userCommonFeatured
|
When the common has been whitelisted |
COMMON_MEMBER_ADDED |
requestToJoin proposer | Congrats! |
user: userJoinedSuccess
|
When the a member was added to the common |
COMMON_MEMBER_REMOVED |
X | X | X | When the a member was removed to the common |
REQUEST_TO_JOIN_CREATED |
common founder | New members want to join ${commonData.name} |
user: requestToJoinSubmitted | When a request to join was created |
REQUEST_TO_JOIN_ACCEPTED |
X | X | X | When a request to join was approved |
REQUEST_TO_JOIN_REJECTED |
requestToJoin proposer | Bad news, your request to join "${commonData.name}" was rejected. |
X | When a request to join was rejected or timed out |
REQUEST_TO_JOIN_EXECUTED |
requestToJoin proposer | X | X | When the payment was successful and the user becomes a member |
FUNDING_REQUEST_CREATED |
common members, excluding the funding proposal creator | A new funding proposal in your Common! |
X | When a funding proposal was created |
FUNDING_REQUEST_ACCEPTED |
fundingRequest proposer | Your funding proposal was approved! |
user: when user details are unknown (e.g. founder) userFundingRequestAcceptedUnknown, when the proposer is from Israel: userFundingRequestAcceptedIsraeli, when the proposer is from a country other than Israel: userFundingRequestAcceptedForeign, when the funding amount is 0: userFundingRequestAcceptedZeroAmount. admin: adminFundingRequestAccepted
|
When a funding proposal was approved |
FUNDING_REQUEST_ACCEPTED_INSUFFICIENT_FUNDS |
fundingRequest proposer | X | user: userFundingRequestAcceptedInsufficientFunds
|
A Funding proposal was approved, but there are no funds to pay for it |
FUNDING_REQUEST_REJECTED |
fundingRequest proposer | X | X | When a funding request is rejected or timed out |
FUNDING_REQUEST_EXECUTED |
X | X | X | X |
VOTE_CREATED |
X | X | X | When a vote created for a proposal |
PAYMENT_CREATED |
X | X | X | After a request to join was accepted, payment created is the first step of payment processing |
PAYMENT_CONFIRMED |
X | X | X | When a payment was approved by circle and has the status confirmed
|
PAYMENT_UPDATED |
X | X | X | When a payment doc has been updated |
PAYMENT_FAILED |
proposal proposer | X | user: userJoinedButFailedPayment
|
When a user’s membership request was approved, but during payment processing in circle, the payment failed |
PAYMENT_PAID |
X | X | X | When a payment actually went through, and the money was transferred. |
PAYOUT_CREATED |
X | X | X | X |
PAYOUT_APPROVED |
X | X | X | X |
PAYOUT_EXECUTED |
X | X | X | X |
PAYOUT_VOIDED |
X | X | X | X |
PAYOUT_COMPLETED |
X | X | X | X |
PAYOUT_FAILED |
X | X | X | X |
CARD_CREATED |
X | X | X | X |
MESSAGE_CREATED |
the users who participate in the discussion, with some limits | New comment! |
X | * Discussion & Funding Proposals: Only members who participate in the discussion will be notified creator of the message does not get notified * Request to join proposals: Only members who participate in the discussion will be notified (so the proposer will not get notified because he cannot participate) |
SUBSCRIPTION_CREATED |
X | X | X | X |
SUBSCRIPTION_PAYMENT_CREATED |
X | X | X | X |
SUBSCRIPTION_PAYMENT_FAILED |
X | X | X | X |
SUBSCRIPTION_PAYMENT_CONFIRMED |
proposal proposer | X | X | When a subscription payment was approved by circle and has the status confirmed
|
SUBSCRIPTION_PAYMENT_STUCK |
X | X | X | X |
SUBSCRIPTION_CANCELED_BY_USER |
subscriber | X | user: subscriptionCanceled
|
When the member cancels her subscription to a common |
SUBSCRIPTION_CANCELED_BY_PAYMENT_FAILURE |
subscriber | X | user: subscriptionChargeFailed
|
When a subscription payment was not successful |
MEMBERSHIP_REVOKED |
X | X | X | X |