Add support for discussion comments in Codebase mirror
(imported from commit 9b37cbf4209ad607966053af9c1ef9979c2d6205)
This commit is contained in:
parent
134e96ad9b
commit
de3033abb3
|
@ -180,12 +180,28 @@ def handle_event(event):
|
||||||
|
|
||||||
comment = raw_props.get('content')
|
comment = raw_props.get('content')
|
||||||
commit = raw_props.get('commit_ref')
|
commit = raw_props.get('commit_ref')
|
||||||
|
|
||||||
|
# If there's a commit id, it's a comment to a commit
|
||||||
|
if commit:
|
||||||
repo_link = raw_props.get('repository_permalink')
|
repo_link = raw_props.get('repository_permalink')
|
||||||
|
|
||||||
url = make_url('projects/%s/repositories/%s/commit/%s' % (project_link, repo_link, commit))
|
url = make_url('projects/%s/repositories/%s/commit/%s' % (project_link, repo_link, commit))
|
||||||
|
|
||||||
subject = "%s commented on %s" % (actor_name, commit)
|
subject = "%s commented on %s" % (actor_name, commit)
|
||||||
content = "%s commented on [%s](%s):\n\n~~~ quote\n%s" % (actor_name, commit, url, comment)
|
content = "%s commented on [%s](%s):\n\n~~~ quote\n%s" % (actor_name, commit, url, comment)
|
||||||
|
else:
|
||||||
|
# Otherwise, this is a Discussion item, and handle it
|
||||||
|
subj = raw_props.get("subject")
|
||||||
|
category = raw_props.get("category")
|
||||||
|
comment_content = raw_props.get("content")
|
||||||
|
|
||||||
|
subject = "Discussion: %s" % (subj,)
|
||||||
|
|
||||||
|
if category:
|
||||||
|
content = "%s started a new discussion in %s:\n\n~~~ quote\n%s\n~~~" % (actor_name, category, comment_content)
|
||||||
|
else:
|
||||||
|
content = "%s posted:\n\n~~~ quote\n%s\n~~~" % (actor_name, comment_content)
|
||||||
|
|
||||||
elif event_type == 'deployment':
|
elif event_type == 'deployment':
|
||||||
stream = config.ZULIP_COMMITS_STREAM_NAME
|
stream = config.ZULIP_COMMITS_STREAM_NAME
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue