Merge branch 'philip/notify-queue-setting' into 'master'

Enable api level setting of queue value.

See merge request grassrootseconomics/cic-internal-integration!184
This commit is contained in:
Philip Wafula 2021-06-29 10:21:43 +00:00
commit 53317cb912

View File

@ -41,11 +41,12 @@ def get_sms_queue_tasks(app, task_prefix='cic_notify.tasks.sms.'):
class Api: class Api:
# TODO: Implement callback strategy # TODO: Implement callback strategy
def __init__(self, queue='cic-notify'): def __init__(self, queue=None):
""" """
:param queue: The queue on which to execute notification tasks :param queue: The queue on which to execute notification tasks
:type queue: str :type queue: str
""" """
self.queue = queue
self.sms_tasks = get_sms_queue_tasks(app) self.sms_tasks = get_sms_queue_tasks(app)
logg.debug('sms tasks {}'.format(self.sms_tasks)) logg.debug('sms tasks {}'.format(self.sms_tasks))
@ -61,13 +62,19 @@ class Api:
""" """
signatures = [] signatures = []
for q in self.sms_tasks: for q in self.sms_tasks:
if not self.queue:
queue = q[0]
else:
queue = self.queue
signature = celery.signature( signature = celery.signature(
q[1], q[1],
[ [
message, message,
recipient, recipient,
], ],
queue=q[0], queue=queue,
) )
signatures.append(signature) signatures.append(signature)