Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting of log type of channel logs and add additional types #605

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

rowanseymour
Copy link
Member

No description provided.

@@ -23,9 +23,11 @@ const (
ChannelLogTypeMsgStatus ChannelLogType = "msg_status"
ChannelLogTypeMsgReceive ChannelLogType = "msg_receive"
ChannelLogTypeEventReceive ChannelLogType = "event_receive"
ChannelLogTypeMultiReceive ChannelLogType = "multi_receive"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when a payload can contain a mixture of things

@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Merging #605 (c8e241b) into main (f37897d) will increase coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #605      +/-   ##
==========================================
+ Coverage   74.38%   74.46%   +0.08%     
==========================================
  Files          98       98              
  Lines       13153    13188      +35     
==========================================
+ Hits         9784     9821      +37     
+ Misses       2670     2668       -2     
  Partials      699      699              
Files Changed Coverage Δ
channel_log.go 90.52% <100.00%> (ø)
handlers/africastalking/africastalking.go 90.42% <100.00%> (ø)
handlers/arabiacell/arabiacell.go 75.80% <100.00%> (ø)
handlers/bandwidth/bandwidth.go 69.03% <100.00%> (ø)
handlers/blackmyna/blackmyna.go 85.54% <100.00%> (ø)
handlers/bongolive/bongolive.go 82.82% <100.00%> (+0.91%) ⬆️
handlers/burstsms/burstsms.go 84.48% <100.00%> (ø)
handlers/clickatell/clickatell.go 91.66% <100.00%> (ø)
handlers/clickmobile/clickmobile.go 80.21% <100.00%> (ø)
handlers/clicksend/clicksend.go 77.96% <100.00%> (ø)
... and 50 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -35,7 +35,7 @@ func init() {
// Initialize is called by the engine once everything is loaded
func (h *handler) Initialize(s courier.Server) error {
h.SetServer(s)
s.AddHandlerRoute(h, http.MethodPost, "receive", h.receiveMessage)
s.AddHandlerRoute(h, http.MethodPost, "receive", courier.ChannelLogTypeUnknown, h.receiveMessage)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for routes where we can't know until we parse the payload.. it's set manually with SetType in the method

// receiveEvent is our HTTP handler function for incoming messages and status updates
func (h *handler) receiveEvent(ctx context.Context, channel courier.Channel, w http.ResponseWriter, r *http.Request, payload *moPayload, clog *courier.ChannelLog) ([]courier.Event, error) {
// receiveEvents is our HTTP handler function for incoming messages and status updates
func (h *handler) receiveEvents(ctx context.Context, channel courier.Channel, w http.ResponseWriter, r *http.Request, payload *moPayload, clog *courier.ChannelLog) ([]courier.Event, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed for clarity

@rowanseymour rowanseymour requested a review from norkans7 July 26, 2023 15:34
@@ -62,6 +62,8 @@ var statusMapping = map[string]courier.MsgStatusValue{
// receiveEvent is our HTTP handler function for incoming messages
func (h *handler) receiveEvent(ctx context.Context, channel courier.Channel, w http.ResponseWriter, r *http.Request, payload *eventPayload, clog *courier.ChannelLog) ([]courier.Event, error) {
if payload.Type == "recipient_delivery_report_sms" {
clog.SetType(courier.ChannelLogTypeEventReceive)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be be courier.ChannelLogTypeMsgStatus?

@rowanseymour rowanseymour merged commit 4a7843f into main Jul 26, 2023
@rowanseymour rowanseymour deleted the better_log_types branch July 26, 2023 16:33
@github-actions github-actions bot locked and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants