-
Notifications
You must be signed in to change notification settings - Fork 1
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
Improve Threema text receiving workflow #700
Improve Threema text receiving workflow #700
Conversation
Gemfile.lock
Outdated
revision: 0819d4099b751a8d0bbda6bb7e14e2ee54b73d85 | ||
branch: master | ||
revision: 1eb86559a6572d22c3d16d800e664bff8483c48f | ||
branch: feature-add-delivery-receipt-support |
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.
see 👆
@@ -3,21 +3,35 @@ | |||
require 'openssl' | |||
|
|||
class Threema::WebhookController < ApplicationController | |||
protect_from_forgery with: :null_session | |||
skip_before_action :require_login | |||
skip_before_action :require_login, :verify_authenticity_token |
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.
we can skip
the verify_authenticity_token
here since it's a webhook and there would not be such a token.
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.
end | ||
|
||
private | ||
|
||
def threema_webhook_params | ||
params.permit(:from, :to, :messageId, :date, :nonce, :box, :mac, :nickname) | ||
end | ||
|
||
def respond_to_unknown_content_and_prevent_retries(contributor) | ||
ThreemaAdapter.new(message: Message.new(text: Setting.telegram_unknown_content_message, recipient: contributor)).send! |
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.
It would be better to have a dedicated Setting.threema_unknown_content_message
because I saw that we mentioned Astrid's personal account in there. This would certainly be different for Threema then.
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.
Cool, didn't catch that part... I've added that in 8c0217a ... I noticed that our Telegram message says we don't support voice, though we do... I'll have to create another ticket to update that, and also remember to do the same for Threema when it gets out of date.
- Threema retry logic will attempt to send the webhook 3 times, 5 minutes apart, if the server does not respond with 200. After that, the message is lost.
- Rescue NameError returned from Threema::Receive::DeliveryReceipt not being declared in threema gem - respond to contributors trying to send files/images with message... return 200 to avoid Threema Gateway API retry logic
036de6d
to
957c941
Compare
- to be able to access the message retrospectively - to keep consistent across the code base
- with Astrid's contact info
- to avoid false positives since is_a? would return true for classes which are inherited from, and even module namespaces
- Calling JSON.generate throws an error, decrypted_message.content is already ready to be used by StringIO.new
- this will be changed in future to send back a message, probably, but for now it's sufficient to avoid retries if we don't know who the user is.
minutes apart, if the server does not respond with 200. After that,
the message is lost.
I'd carry on working on this
PR
, I guess... Unless, we want to merge this in, then I could open antother PR.
Next steps:
Threema::Receive::Text
Threema::Receive::File
separate issue created: Add support for Threema::Receive::File type #706Threema::Receive::Image
separate issue created: Add support for Threema::Receive::Image #707Threema::Receive::DeliveryReceipt
separate issue created: Add support for Threema::Receive::DeliveryReceipt #708