bitcart/bitcart

[BUG] SMTP notifications not working - port number interpreted as string instead of integer

KarolTrzeszczkowski opened this issue · 2 comments

Describe the bug
When using e-mail notification provider I got an error and no notifications sent.

To Reproduce
Steps to reproduce the behavior:

  1. Create a store,

  2. Add notification provider "email" with a custom mail server. My settings:
    Zrzut ekranu z 2021-10-05 15-49-23

  3. Make a purchase, go through checkout,

  4. The invoice changes to confirmed but the interface still waits for payment,

  5. There's a traceback in the log informing about notifiers error Error with sent data: '465' is not of type 'integer' apparently the port is taken as a string instead od as an int.

Expected behavior
Should have sent a notification and proceed with a success info

Log

2021-10-05 13:39:02,291 - [PID 17] - api.crud.invoices.create_invoice [line 20] - DEBUG - {'created': datetime.datetime(2021, 10, 5, 13, 39, 2, 274624), 'price': Decimal('0.1'), 'store_id': 'LTgKBHWfOBrQzRHWKUngyvdUDfdWVDyA', 'currency': 'mXRG', 'paid_currency': '', 'order_id': '', 'notification_url': '', 'redirect_url': '', 'buyer_email': 'licho@ergon.moe', 'promocode': None, 'discount': None, 'status': 'pending', 'products': {'QKHVqXkmSCtseYBSpDeIpm': 1}}
2021-10-05 13:39:02,346 - [PID 17] - api.crud.invoices.update_invoice_payments [line 123] - INFO - Started adding invoice payments for invoice VwKndOcShzfnNpQKKOxXQJ
2021-10-05 13:39:02,400 - [PID 17] - api.crud.invoices.update_invoice_payments [line 133] - INFO - Successfully added 1 payment methods to invoice VwKndOcShzfnNpQKKOxXQJ
2021-10-05 13:39:16,277 - [PID 1] - api.invoices.update_status [line 220] - INFO - Updating status of invoice VwKndOcShzfnNpQKKOxXQJ with payment method XRG to paid
2021-10-05 13:39:16,302 - [PID 1] - api.invoices.update_status [line 220] - INFO - Updating status of invoice VwKndOcShzfnNpQKKOxXQJ with payment method XRG to complete
2021-10-05 13:39:16,312 - [PID 1] - api.invoices.invoice_notification [line 173] - INFO - Invoice VwKndOcShzfnNpQKKOxXQJ complete, sending notifications...
2021-10-05 13:39:16,323 - [PID 1] - api.utils.templates.get_template [line 28] - INFO - Template matching "notification" for store LTgKBHWfOBrQzRHWKUngyvdUDfdWVDyA: selected default template
2021-10-05 13:39:16,339 - [PID 1] - api.utils.logging.log_errors [line 14] - ERROR - 
Traceback (most recent call last):
  File "/app/api/utils/logging.py", line 12, in log_errors
    yield
  File "/app/api/invoices.py", line 132, in new_payment_handler
    await process_electrum_status(invoice, method, xpub, status)
  File "/app/api/invoices.py", line 111, in process_electrum_status
    await update_confirmations(invoice, method, confirmations=0)  # to trigger complete for stores accepting 0-conf
  File "/app/api/invoices.py", line 143, in update_confirmations
    await update_status(invoice, status, method)
  File "/app/api/invoices.py", line 223, in update_status
    await invoice_notification(invoice, status)
  File "/app/api/invoices.py", line 175, in invoice_notification
    await utils.notifications.notify(store, await utils.templates.get_notify_template(store, invoice))
  File "/app/api/utils/notifications.py", line 27, in notify
    notifiers.notify(provider.provider, message=text, **provider.data)
  File "/usr/local/lib/python3.7/site-packages/notifiers/core.py", line 365, in notify
    return get_notifier(provider_name=provider_name, strict=True).notify(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/notifiers/core.py", line 303, in notify
    data = self._process_data(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/notifiers/core.py", line 235, in _process_data
    self._validate_data(data)
  File "/usr/local/lib/python3.7/site-packages/notifiers/core.py", line 208, in _validate_data
    raise BadArguments(validation_error=msg, provider=self.name, data=data)
notifiers.exceptions.BadArguments: Error with sent data: '465' is not of type 'integer'

Desktop:

  • OS: Linux
  • Version BitcartCC v0.6.0.1

This is caused by not casting arguments to int when needed
We should properly parse the schema object of notification providers, see:
https://notifiers.readthedocs.io/en/latest/usage.html#provider-schema
Another bug we found is that when changing notification providers the old data isn't cleared which causes arguments to be passed which aren't supported. This also needs fixing