from django.db import models
from django.contrib.auth.models import User, UserManager
-from astakos.im.settings import DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, AUTH_TOKEN_DURATION, BILLING_FIELDS, QUEUE_CONNECTION
+from astakos.im.settings import DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, AUTH_TOKEN_DURATION, BILLING_FIELDS, QUEUE_EXCHANGE
from synnefo.lib.queue import exchange_connect, exchange_send, exchange_close, Receipt
QUEUE_CLIENT_ID = 3 # Astakos.
return True
return False
- if QUEUE_CONNECTION and should_send(user):
+ if QUEUE_EXCHANGE and should_send(user):
l = [[elem, str(user.__getattribute__(elem))] for elem in BILLING_FIELDS]
details = dict(l)
+ details['eventType'] = 'create' if not user.id else 'modify'
body = Receipt(QUEUE_CLIENT_ID, user.email, '', 0, details).format()
- msgsubtype = 'create' if not user.id else 'modify'
- exchange = '%s.%s.#' %(QUEUE_CONNECTION, msgsubtype)
- conn = exchange_connect(exchange)
- routing_key = exchange.replace('#', body['id'])
+ conn = exchange_connect(QUEUE_EXCHANGE)
+ routing_key = QUEUE_EXCHANGE.replace('#', body['id'])
exchange_send(conn, routing_key, body)
exchange_close(conn)
\ No newline at end of file
BILLING_FIELDS = getattr(settings, 'ASTAKOS_BILLING_FIELDS', ['id', 'is_active', 'provider', 'third_party_identifier'])
# Queue for billing.
-QUEUE_CONNECTION = getattr(settings, 'ASTAKOS_QUEUE_CONNECTION', None) # Example: 'rabbitmq://guest:guest@localhost:5672/astakos.userEvent'
\ No newline at end of file
+QUEUE_EXCHANGE = getattr(settings, 'ASTAKOS_QUEUE_EXCHANGE', None) # Example: 'rabbitmq://guest:guest@localhost:5672/astakos.userEvent.#'
\ No newline at end of file