forked from Ilhasoft/mailroom
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/urn-brain
- Loading branch information
Showing
6 changed files
with
160 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
1.39.1 | ||
---------- | ||
* Update goflow to v1.4.1 | ||
|
||
1.39.0 | ||
---------- | ||
* Feat: WhatsApp Order Details | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package handlers | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/nyaruka/goflow/flows" | ||
"github.com/nyaruka/goflow/flows/events" | ||
"github.com/nyaruka/mailroom/core/hooks" | ||
"github.com/nyaruka/mailroom/core/models" | ||
"github.com/nyaruka/mailroom/runtime" | ||
|
||
"github.com/jmoiron/sqlx" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func init() { | ||
models.RegisterEventHandler(events.TypeMetaCalled, handleMetaCalled) | ||
} | ||
|
||
// handleServiceCalled is called for each service called event | ||
func handleMetaCalled(ctx context.Context, rt *runtime.Runtime, tx *sqlx.Tx, oa *models.OrgAssets, scene *models.Scene, e flows.Event) error { | ||
event := e.(*events.MetaCalledEvent) | ||
|
||
run, _ := scene.Session().FindStep(e.StepUUID()) | ||
flow, _ := oa.Flow(run.FlowReference().UUID) | ||
|
||
if flow != nil { | ||
// create a log for each HTTP call | ||
for _, httpLog := range event.HTTPLogs { | ||
logrus.WithFields(logrus.Fields{ | ||
"contact_uuid": scene.ContactUUID(), | ||
"session_id": scene.SessionID(), | ||
"url": httpLog.URL, | ||
"status": httpLog.Status, | ||
"elapsed_ms": httpLog.ElapsedMS, | ||
}).Debug("meta called") | ||
|
||
log := models.NewWebhookCalledLog( | ||
oa.OrgID(), | ||
flow.(*models.Flow).ID(), | ||
httpLog.URL, | ||
httpLog.StatusCode, | ||
httpLog.Request, | ||
httpLog.Response, | ||
httpLog.Status != flows.CallStatusSuccess, | ||
time.Millisecond*time.Duration(httpLog.ElapsedMS), | ||
httpLog.Retries, | ||
event.CreatedOn(), | ||
scene.ContactID(), | ||
) | ||
scene.AppendToEventPreCommitHook(hooks.InsertHTTPLogsHook, log) | ||
} | ||
} | ||
|
||
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