Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #933 from mpurzynski/large_strings_github
Browse files Browse the repository at this point in the history
Truncate, if present, the GitHub Webhook's pr_body field
  • Loading branch information
pwnbus committed Nov 5, 2018
2 parents acc0002 + 90b746e commit 4d07a1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mq/plugins/large_strings.py
Expand Up @@ -6,7 +6,7 @@

class message(object):
def __init__(self):
self.registration = ['nubis_events_prod']
self.registration = ['nubis_events_prod', 'githubeventsqs']
self.priority = 20
self.MAX_STRING_LENGTH = 3000

Expand All @@ -24,6 +24,12 @@ def onMessage(self, message, metadata):
message['details']['cmdline'] = message['details']['cmdline'][:self.MAX_STRING_LENGTH]
message['details']['cmdline'] += ' ...'

if 'pr_body' in message['details']:
if type(message['details']['pr_body']) in (str, unicode) \
and len(message['details']['pr_body']) > self.MAX_STRING_LENGTH:
message['details']['pr_body'] = message['details']['pr_body'][:self.MAX_STRING_LENGTH]
message['details']['pr_body'] += ' ...'

if 'summary' in message:
if type(message['summary']) in (str, unicode) \
and len(message['summary']) > self.MAX_STRING_LENGTH:
Expand Down

0 comments on commit 4d07a1e

Please sign in to comment.