forked from rapidpro/mailroom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to goflow v0.61.0 and provide email service to engine
- Loading branch information
1 parent
f0c5b98
commit 7cc2d94
Showing
7 changed files
with
77 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package hooks | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/nyaruka/goflow/flows" | ||
"github.com/nyaruka/goflow/flows/events" | ||
"github.com/nyaruka/mailroom/models" | ||
|
||
"github.com/gomodule/redigo/redis" | ||
"github.com/jmoiron/sqlx" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func init() { | ||
models.RegisterEventHook(events.TypeEmailSent, handleEmailSent) | ||
} | ||
|
||
// handleEmailCreated event queues an email to be sent later on | ||
func handleEmailSent(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *models.OrgAssets, session *models.Session, e flows.Event) error { | ||
|
||
// goflow now sends email so just log the event | ||
event := e.(*events.EmailSentEvent) | ||
logrus.WithFields(logrus.Fields{ | ||
"contact_uuid": session.ContactUUID(), | ||
"session_id": session.ID(), | ||
"body": event.Body, | ||
"to": event.To, | ||
}).Debug("email sent") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters