Skip to content

Commit

Permalink
Merge b132f24 into 4543cec
Browse files Browse the repository at this point in the history
  • Loading branch information
Shriyanshagro committed Aug 10, 2018
2 parents 4543cec + b132f24 commit 4603909
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
21 changes: 10 additions & 11 deletions src/collective/ifttt/actions/ifttt.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def __call__(self, *args, **kwargs):
secret_key = api.portal.get_registry_record('ifttt.ifttt_secret_key')
ifttt_trigger_url = 'https://maker.ifttt.com/trigger/' + \
ifttt_event_name + '/with/key/' + secret_key
payload = {'title': title, 'url': url}
payload = {'value3': title, 'value2': url}

# define 3rd payload as chosen by user
if payload_option == PAYLOAD_DESCRIPTION:
payload[payload_option] = self.context.description
payload['value1'] = self.context.description
elif payload_option == PAYLOAD_USERNAME:
payload[payload_option] = api.user.get_current().getId()
payload['value1'] = api.user.get_current().getId()
elif payload_option == PAYLOAD_START:
try:
'''
Expand All @@ -129,23 +129,22 @@ def __call__(self, *args, **kwargs):
because their start date & time should dynamically adapt to the
next occurrence.
'''
payload[payload_option] = IEventAccessor(self.context).start
payload['value1'] = IEventAccessor(self.context).start
except TypeError:
'''
when the context does implement or have
registered adapter for IEventAccessor interface/contract
'''
payload[payload_option] = None
payload['value1'] = None
'''we expect default behaviour here until
indirection interface is needed to call IFTTT'''
r = queryMultiAdapter((self.element, getRequest()),
IRequestsLibrary,
default=requests)

req = queryMultiAdapter((self.element, getRequest()),
IRequestsLibrary,
default=requests)
logger.info('Calling Post request to IFTTT')
try:

r.post(ifttt_trigger_url, data=payload, timeout=self.timeout)
# Bug payloads are not filtered by IFTTT
req.post(ifttt_trigger_url, data=payload, timeout=self.timeout)

# show this logging message to Plone user as notification
api.portal.show_message(
Expand Down
6 changes: 4 additions & 2 deletions src/collective/ifttt/easyform.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ def onSuccess(self, fields, request):
return False

payload = {}

count = 1
# get fields data as payload data
for i in self.payload_fields:
payload[i] = fields.get(i)
key = 'value' + str(count)
payload[key] = fields.get(i)
count += 1

# IFTTTActionExecutor
timeout = 120
Expand Down

0 comments on commit 4603909

Please sign in to comment.