Commit 660c7a4f authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

integration with aquarium: Progress II

Refs: #1824
parent 9c01d9d1
......@@ -41,7 +41,7 @@ from base64 import b64encode
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.
......@@ -162,13 +162,12 @@ def report_user_event(user):
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
......@@ -62,4 +62,4 @@ RECAPTCHA_OPTIONS = getattr(settings, 'ASTAKOS_RECAPTCHA_OPTIONS', {'theme': 'wh
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment