Skip to content

Add delete request endpoint that creates a channel event for FBA chan…#834

Open
norkans7 wants to merge 4 commits intomainfrom
channel-events-delete-request
Open

Add delete request endpoint that creates a channel event for FBA chan…#834
norkans7 wants to merge 4 commits intomainfrom
channel-events-delete-request

Conversation

@norkans7
Copy link
Copy Markdown
Contributor

…nels

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 72.22222% with 10 lines in your changes missing coverage. Please review.

Project coverage is 70.25%. Comparing base (3ed6f95) to head (1c888d3).

Files with missing lines Patch % Lines
handlers/meta/handlers.go 81.25% 4 Missing and 2 partials ⚠️
handlers/test.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #834   +/-   ##
=======================================
  Coverage   70.25%   70.25%           
=======================================
  Files         114      114           
  Lines       13106    13141   +35     
=======================================
+ Hits         9207     9232   +25     
- Misses       3208     3216    +8     
- Partials      691      693    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rowanseymour
Copy link
Copy Markdown
Member

@norkans7 can you put the changes to write event UUIDs in a separate PR?

@norkans7 norkans7 force-pushed the channel-events-delete-request branch from 55bd95f to 2ce0341 Compare February 14, 2025 15:22
@norkans7 norkans7 changed the base branch from main to channel-event-uuid February 14, 2025 15:23
@norkans7 norkans7 force-pushed the channel-events-delete-request branch from 2ce0341 to 2a6d194 Compare February 14, 2025 15:25
@norkans7
Copy link
Copy Markdown
Contributor Author

@rowanseymour I moved that to #835 and rebased this on that branch

Base automatically changed from channel-event-uuid to main February 14, 2025 15:31
@norkans7 norkans7 force-pushed the channel-events-delete-request branch from 2a6d194 to 1c71f27 Compare March 4, 2025 14:35
@norkans7
Copy link
Copy Markdown
Contributor Author

norkans7 commented Mar 4, 2025

contains #846

@norkans7 norkans7 force-pushed the channel-events-delete-request branch from 1c71f27 to 72bc8c9 Compare March 4, 2025 15:40
Comment thread handlers/meta/handlers.go Outdated
data := make([]any, 0, 2)

payloadJson, _ := json.Marshal(payload)
sentry.CaptureMessage(fmt.Sprintf("Data Deletion Request: %s", payloadJson))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be on the mailroom side

Comment thread handlers/meta/handlers.go Outdated
return nil, err
}

confirmationURL := fmt.Sprintf("https://%s/channels/events/read/%s/", h.Server().Config().Domain, event.UUID())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@norkans7 @ericnewcomer need to make a decision on this URL.. is it maybe odd to have event UUID in the URL and be the confirmation code? Should we use contact UUID instead? Is there a vulnerability there allowing enumeration of contact UUIDs? My inclination is a really generic URL like https://<domain>/public/forgetme/ with a UUID as the confirmation code that they enter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think https://<domain>/public/forgetme/ with the confirmation code being the event UUID is fine

so the view will be a form and we will not query the contacts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I find that once we submit the form, we need a page to redirect to so i think we need to keep the event read view for that.
And that approach gives us flexibility to change that behavior with changing the link we send for the confirmation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I used the same view with a get param
https://github.com/nyaruka/rapidpro/pull/5928/files

@norkans7 norkans7 force-pushed the channel-events-delete-request branch from 72bc8c9 to 5690d30 Compare March 6, 2025 14:35
@norkans7 norkans7 force-pushed the channel-events-delete-request branch from 5690d30 to 1c888d3 Compare March 6, 2025 14:37
Comment thread handlers/meta/handlers.go
// GetChannel returns the channel
func (h *handler) GetChannel(ctx context.Context, r *http.Request) (courier.Channel, error) {
if r.Method == http.MethodGet {
if r.Method == http.MethodGet || r.URL.Path == "/c/fba/delete" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@norkans7 I'm not getting why we need this..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We use the same URL for all channels and this lookup the channel for the message however for the delete request we do not get info about the channel at all to be able to look it up so will ignore and the URN we get will be unique since they page scoped

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but how can we look up a URN without a channel? Don't we need channel to get org_id ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, this will not work without a valid channel, the request I expect we get on that also cannot allow us to lookup the channel

I guess we remove the check for the contacts exists in the DB and rely on the URN that we know if page scoped

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can't create a channel event without a channel... and we don't gain much from making it mailroom's problem to determine if a URN exists - we don't have an index on URN without org id. Argh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants