-
Notifications
You must be signed in to change notification settings - Fork 0
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
OLH-1053 update reported flag on activity #186
Conversation
a62931d
to
e802698
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good - nice one!
I'd forgotten this table still had a composite primary key of user_id
and timestamp
which I think has made your work more complicated than it should have been. Sorry about that. We should have already updated the table first to use the new primary key of user_id
and event_id
we defined in ADR 0010. You've done the right thing here in working with the primary key as it it but it does need to change for this to be robust as we should expect to see multiple events for a user with the same timestamp at some point since timestamp is only to the nearest second.
I think what we should do is update the indices now in your PR. Then you could get rid of the getItemByEventId
function and update markEventAsReported
to use the user_id
and event_id
keys. We can rely on DynamoDB to enforce uniqueness for the primary key. We'll also be able to get rid of the global secondary indices which will save us a bit of money.
The first part of the table definition would then look like this:
UserActivityLogStore:
Type: AWS::DynamoDB::Table
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
AttributeDefinitions:
- AttributeName: user_id
AttributeType: S
- AttributeName: event_id
AttributeType: S
BillingMode: PAY_PER_REQUEST
TableName: !Ref ActivityLogStoreTableName
KeySchema:
- AttributeName: user_id
KeyType: HASH
- AttributeName: event_id
KeyType: RANGE
Again, sorry for making this harder than it needed to be! Let me know if you want to chat about any of this in more detail.
Make sense, thanks @alex9smith. I wonder if it's worth doing that in a separate ticket, as there are a places in other lambdas where the timestamp is used in a query (here for example). So we'd have to make the change there, increasing the scope of this PR beyond what's required in the ticket. |
Ah yeah - that's a good point. I'd forgotten this was still in the delete lambda as well so I thought it'd still be only changes to this lambda. I'll write up a ticket to change the primary key for next sprint. |
9c1b8ae
to
a196aac
Compare
Create a new lambda that subscribes to the SuspiciousActivity SNS topic. When triggered, the lambda will update the record for that activity (in the activity_log table), setting reported_suspicious to true.
a196aac
to
6886032
Compare
Proposed changes
When a user reports an activity as suspicious, we should record that in the activity log, so that we can ensure we don't report things twice, and provide feedback to the user.
What changed
activity_log
table, so that we can query the table based on theevent_id
reported_suspicious
totrue
Why did it change
When we build functionality for users to report activity as suspicious, we want to a) give feedback to the user, and b) ensure that we don't make multiple tickets in zendesk.
By setting this flag to true, we can show that to the user, so that they know we have received the report. This will work even if there is an issue with Zendesk, and we haven't got a ticket number yet.
Related links
#181
Checklists
Environment variables or secrets
Testing
I manually tested this by...
Deploying the changes to the dev environment
Getting an
![Screenshot 2024-01-30 at 14 22 01](https://private-user-images.githubusercontent.com/748653/300841652-e37a2417-bf2d-4e07-b424-45fea9acfc9d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExNTM1NzQsIm5iZiI6MTcyMTE1MzI3NCwicGF0aCI6Ii83NDg2NTMvMzAwODQxNjUyLWUzN2EyNDE3LWJmMmQtNGUwNy1iNDI0LTQ1ZmVhOWFjZmM5ZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxNlQxODA3NTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00ZGQ3NDQzNGU4ZTA4ZTM4YzU2OTcxNjliNTJjODZmNzliMDg2OTM2ZGIwYmQyNWYzYzcxMzZjYmNlMzJhNmI5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.o-Cxb6e1PN4OSpRjZNdQxC2kegU7jypoZTfoiUDt8LU)
event_id
from theactivity_log
table (through the AWS console)Publishing a message on the
SuspiciousActivity
topic with the following body (replacing event_id with the one I got in the previous step)Refreshing the DyanamoDB view, and checking that the
reported_suspicious
property has been set to true for the event I chose.