openware / barong

Barong auth server
https://www.openware.com
Apache License 2.0
139 stars 262 forks source link

Getting duplicate emails being sent for every template #1176

Closed leocape closed 3 years ago

leocape commented 3 years ago

Using Barong 2.5x - tried 2.5.1 -> 2.5.17 get the same result for each version.

Each email that is sent will be sent twice immediately

mailer logs: "level":"INFO","time":"2020-11-11 21:12:46 +0000","message":"Listening for events."} {"level":"DEBUG","time":"2020-11-11 21:12:54 +0000","message":" \u001b[1m\u001b[35m (0.6ms)\u001b[0m \u001b[1m\u001b[35mSET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES') , ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483\u001b[0m"} {"level":"DEBUG","time":"2020-11-11 21:12:55 +0000","message":" \u001b[1m\u001b[36mUser Load (0.7ms)\u001b[0m \u001b[1m\u001b[34mSELECTusers.* FROMusersWHEREusers.uid= 'ID2375964C3C' LIMIT 1\ u001b[0m"} {"level":"DEBUG","time":"2020-11-11 21:12:55 +0000","message":" \u001b[1m\u001b[36mProfile Load (0.7ms)\u001b[0m \u001b[1m\u001b[34mSELECTprofiles.* FROMprofilesWHEREprofiles.user_id= 46\u001b [0m"} {"level":"INFO","time":"2020-11-11 21:12:55 +0000","message":" Rendering postmaster/session_create.en.html.erb within layouts/mailer"} {"level":"INFO","time":"2020-11-11 21:12:55 +0000","message":" Rendered postmaster/session_create.en.html.erb within layouts/mailer (4.2ms)"} {"level":"DEBUG","time":"2020-11-11 21:12:55 +0000","message":"Postmaster#process_payload: processed outbound mail in 16.8ms"} {"level":"INFO","time":"2020-11-11 21:12:55 +0000","message":"Sent mail to email@domain.com (204.2ms)"} email template html continues ->

Mailer.yml

keychain:
  barong:
    algorithm: RS256
    value: "<%= @barong_public_key %>"
  peatio:
    algorithm: RS256
    value: "<%= @barong_public_key %>"

exchanges:
  barong_system:
    name: barong.events.system
    signer: barong
  barong_model:
    name: barong.events.model
    signer: barong
  peatio:
    name: peatio.events.model
    signer: peatio

events:
  - name: Email Confirmation
    key: user.email.confirmation.token
    exchange: barong_system
    templates:
      EN:
        subject: Registration Confirmation
        template_path: email_confirmation.en.html.erb
      ru:
        subject: Подтверждение Регистрации
        template_path: email_confirmation.ru.html.erb

  - name: Password Reset
    key: user.password.reset.token
    exchange: barong_system
    templates:
      EN:
        subject: Password Reset
        template_path: password_reset.en.html.erb
      ru:
        subject: Сброс Пароля
        template_path: password_reset.ru.html.erb

  - name: Label Created
    key: label.created
    exchange: barong_model
    templates:
      EN:
        subject: Your account has been fully verified
        template_path: label.en.html.erb

  - name: Session Create
    key: session.create
    exchange: barong_system
    templates:
      EN:
        subject: New Login
        template_path: session_create.en.html.erb

  - name: Deposit Accepted
    key: deposit.updated
    exchange: peatio
    templates:
      EN:
        subject: Deposit Accepted
        template_path: deposit_accepted.en.html.erb

  - name: Withdrawal Succeed
    key: withdraw.updated
    exchange: peatio
    templates:
      EN:
        subject: Withdrawal Succeed
        template_path: withdraw_succeed.en.html.erb

  - name: New Beneficiary
    key: beneficiary.created
    exchange: peatio
    templates:
      EN:
        subject: New Beneficiary
        template_path: new_beneficiary.en.html.erb
leocape commented 3 years ago

Closing as, after restarting all the services, the duplicate emials have stopped. Not sure what was causing the duplicates. but I had upgraded Barong from 2.4 to 2.5, had only restarted Barong and mailer, and no other services. Did no upgrade any other images.

edit: however, if making a change to mailer.yml, restarting mailer then causes the duplicates, if I restart the entire stack then the duplicates go away. But Im not sure which specific service also needs the restart