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

Improve Threema text receiving workflow #700

Merged
merged 15 commits into from
Feb 11, 2021

Conversation

mattwr18
Copy link
Contributor

@mattwr18 mattwr18 commented Feb 9, 2021

  • 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.

I'd carry on working on this PR, I guess... Unless, we want to merge this in, then I could open ant
other PR.

Next steps:

@mattwr18 mattwr18 changed the title Respond with 200 if reply saved, or service unavailable Improve Threema text receiving workflow Feb 10, 2021
Gemfile.lock Outdated
revision: 0819d4099b751a8d0bbda6bb7e14e2ee54b73d85
branch: master
revision: 1eb86559a6572d22c3d16d800e664bff8483c48f
branch: feature-add-delivery-receipt-support
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

Copy link
Collaborator

@roschaefer roschaefer left a comment

Choose a reason for hiding this comment

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

OK

This looks good for me!

I will not hit the merge button because I left some optional improvements we might want to consider.

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!
Copy link
Collaborator

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.

Copy link
Contributor Author

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
@mattwr18 mattwr18 force-pushed the 360-add-threema-support-receive-file-and-image branch from 036de6d to 957c941 Compare February 11, 2021 14:34
- to be able to access the message retrospectively
- to keep consistent across the code base
- 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.
@mattwr18 mattwr18 merged commit 456e8e7 into master Feb 11, 2021
@mattwr18 mattwr18 deleted the 360-add-threema-support-receive-file-and-image branch February 11, 2021 14:46
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