Esempio n. 1
0
    def process_event(self):
        number = self.payload.get('issue', {}).get('number', None)
        subject = self.payload.get('issue', {}).get('title', None)
        github_url = self.payload.get('issue', {}).get('html_url', None)
        github_user_id = self.payload.get('issue', {}).get('user', {}).get('id', None)
        github_user_name = self.payload.get('issue', {}).get('user', {}).get('login', None)
        github_user_url = self.payload.get('issue', {}).get('user', {}).get('html_url', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)
        description = self.payload.get('issue', {}).get('body', None)
        description = replace_github_references(project_url, description)
        state = self.payload.get('issue', {}).get('state', None)

        user = get_github_user(github_user_id)

        if not all([subject, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        action = self.payload.get('action', None)

        if action == "labeled" or action == "unlabeled":
            self._process_label_changed(user, github_url)
        elif action == "edited":
            self._process_edited(subject, github_url, user, description)
        elif action == "closed" or action == "reopened":
            self._process_status_changed(github_url, user, state)
        elif action == "opened":
            self._process_opened(number, subject, github_url, user, github_user_name, github_user_url, project_url, description)
        else:
            raise ActionSyntaxException(_("Invalid issue information"))            
Esempio n. 2
0
    def process_event(self):
        if self.payload.get('action', None) != "created":
            raise ActionSyntaxException(_("Invalid issue comment information"))

        github_url = self.payload.get('issue', {}).get('html_url', None)
        comment_message = self.payload.get('comment', {}).get('body', None)
        github_user = self.payload.get('sender', {}).get('id', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)
        comment_message = replace_github_references(project_url,
                                                    comment_message)

        if not all([comment_message, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue comment information"))

        issues = Issue.objects.filter(
            external_reference=["github", github_url])
        tasks = Task.objects.filter(external_reference=["github", github_url])
        uss = UserStory.objects.filter(
            external_reference=["github", github_url])

        for item in list(issues) + list(tasks) + list(uss):
            snapshot = take_snapshot(
                item,
                comment=_("From GitHub:\n\n{}".format(comment_message)),
                user=get_github_user(github_user))
            send_notifications(item, history=snapshot)
Esempio n. 3
0
    def _change_status(self, ref, status_slug, bitbucket_user):
        if Issue.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Issue
            statusClass = IssueStatus
        elif Task.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Task
            statusClass = TaskStatus
        elif UserStory.objects.filter(project=self.project, ref=ref).exists():
            modelClass = UserStory
            statusClass = UserStoryStatus
        else:
            raise ActionSyntaxException(
                _("The referenced element doesn't exist"))

        element = modelClass.objects.get(project=self.project, ref=ref)

        try:
            status = statusClass.objects.get(project=self.project,
                                             slug=status_slug)
        except statusClass.DoesNotExist:
            raise ActionSyntaxException(_("The status doesn't exist"))

        element.status = status
        element.save()

        snapshot = take_snapshot(
            element,
            comment=_("Status changed from BitBucket commit"),
            user=get_bitbucket_user(bitbucket_user))
        send_notifications(element, history=snapshot)
Esempio n. 4
0
    def _change_status(self, ref, status_slug, github_user, commit):
        if Issue.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Issue
            statusClass = IssueStatus
        elif Task.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Task
            statusClass = TaskStatus
        elif UserStory.objects.filter(project=self.project, ref=ref).exists():
            modelClass = UserStory
            statusClass = UserStoryStatus
        else:
            raise ActionSyntaxException(
                _("The referenced element doesn't exist"))

        element = modelClass.objects.get(project=self.project, ref=ref)

        try:
            status = statusClass.objects.get(project=self.project,
                                             slug=status_slug)
        except statusClass.DoesNotExist:
            raise ActionSyntaxException(_("The status doesn't exist"))

        element.status = status
        element.save()

        github_user_id = github_user.get('id', None)
        github_user_name = github_user.get('login', None)
        github_user_url = github_user.get('html_url', None)
        commit_id = commit.get("id", None)
        commit_url = commit.get("url", None)
        commit_message = commit.get("message", None)

        if (github_user_id and github_user_name and github_user_url
                and commit_id and commit_url and commit_message):
            comment = _(
                "Status changed by [@{github_user_name}]({github_user_url} "
                "\"See @{github_user_name}'s GitHub profile\") "
                "from GitHub commit [#{commit_id}]({commit_url} "
                "\"See commit '#{commit_id}: {commit_message}'\").").format(
                    github_user_name=github_user_name,
                    github_user_url=github_user_url,
                    commit_id=commit_id[:7],
                    commit_url=commit_url,
                    commit_message=commit_message)

        else:
            comment = _("Status changed from GitHub commit.")

        snapshot = take_snapshot(element,
                                 comment=comment,
                                 user=get_github_user(github_user_id))
        send_notifications(element, history=snapshot)
Esempio n. 5
0
def get_status_from_slug(project, element, status_slug):
    if isinstance(element, Issue):
        status_class = IssueStatus
    elif isinstance(element, Task):
        status_class = TaskStatus
    elif isinstance(element, UserStory):
        status_class = UserStoryStatus
    else:
        raise ActionSyntaxException(_("The referenced element doesn't exist"))

    try:
        return status_class.objects.get(project=project, slug=status_slug)
    except status_class.DoesNotExist:
        raise ActionSyntaxException(_("The status doesn't exist"))
Esempio n. 6
0
    def process_event(self):
        if self.payload.get('action', None) != "opened":
            return

        subject = self.payload.get('issue', {}).get('title', None)
        description = self.payload.get('issue', {}).get('body', None)
        github_url = self.payload.get('issue', {}).get('html_url', None)
        github_user = self.payload.get('issue', {}).get('user',
                                                        {}).get('id', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)

        if not all([subject, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(project=self.project,
                                     subject=subject,
                                     description=replace_github_references(
                                         project_url, description),
                                     status=self.project.default_issue_status,
                                     type=self.project.default_issue_type,
                                     severity=self.project.default_severity,
                                     priority=self.project.default_priority,
                                     external_reference=['github', github_url],
                                     owner=get_github_user(github_user))
        take_snapshot(issue, user=get_github_user(github_user))

        snapshot = take_snapshot(issue,
                                 comment=_("Created from GitHub"),
                                 user=get_github_user(github_user))
        send_notifications(issue, history=snapshot)
Esempio n. 7
0
    def process_event(self):
        if self.ignore():
            return

        data = self.get_data()

        if not all([data['subject'], data['url']]):
            raise ActionSyntaxException(_("Invalid issue information"))

        user = self.get_user(data['user_id'], self.platform_slug)

        issue = Issue.objects.create(
            project=self.project,
            subject=data['subject'],
            description=data['description'],
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=[self.platform_slug, data['url']],
            owner=user)
        take_snapshot(issue, user=user)

        comment = self.generate_new_issue_comment(**data)

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
    def process_event(self):
        if self.ignore():
            return

        data = self.get_data()

        if not all([data["comment_message"], data["url"]]):
            raise ActionSyntaxException(_("Invalid issue comment information"))

        comment = self.generate_issue_comment_message(**data)

        issues = Issue.objects.filter(
            external_reference=[self.platform_slug, data["url"]]
        )
        tasks = Task.objects.filter(
            external_reference=[self.platform_slug, data["url"]]
        )
        uss = UserStory.objects.filter(
            external_reference=[self.platform_slug, data["url"]]
        )

        for item in list(issues) + list(tasks) + list(uss):
            snapshot = take_snapshot(
                item,
                comment=comment,
                user=self.get_user(data["user_id"], self.platform_slug),
            )
            send_notifications(item, history=snapshot)
Esempio n. 9
0
    def process_event(self):
        if self.payload.get('object_attributes', {}).get("action", "") != "open":
            return

        subject = self.payload.get('object_attributes', {}).get('title', None)
        description = self.payload.get('object_attributes', {}).get('description', None)
        gitlab_reference = self.payload.get('object_attributes', {}).get('url', None)

        project_url = None
        if gitlab_reference:
            project_url = os.path.basename(os.path.basename(gitlab_reference))

        if not all([subject, gitlab_reference, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=replace_gitlab_references(project_url, description),
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=['gitlab', gitlab_reference],
            owner=get_gitlab_user(None)
        )
        take_snapshot(issue, user=get_gitlab_user(None))

        snapshot = take_snapshot(issue, comment="Created from GitLab", user=get_gitlab_user(None))
        send_notifications(issue, history=snapshot)
Esempio n. 10
0
    def process_event(self):
        number = self.payload.get('issue', {}).get('id', None)
        subject = self.payload.get('issue', {}).get('title', None)

        bitbucket_url = self.payload.get('issue',
                                         {}).get('links',
                                                 {}).get('html',
                                                         {}).get('href', None)
        bitbucket_user_id = self.payload.get('actor',
                                             {}).get('user',
                                                     {}).get('uuid', None)
        bitbucket_user_name = self.payload.get('actor',
                                               {}).get('user', {}).get(
                                                   'username', None)
        bitbucket_user_url = self.payload.get('actor', {}).get('user', {}).get(
            'links', {}).get('html', {}).get('href')

        project_url = self.payload.get('repository',
                                       {}).get('links',
                                               {}).get('html',
                                                       {}).get('href', None)

        comment_message = self.payload.get('comment',
                                           {}).get('content',
                                                   {}).get('raw', '')
        comment_message = replace_bitbucket_references(project_url,
                                                       comment_message)

        user = get_bitbucket_user(bitbucket_user_id)

        if not all([comment_message, bitbucket_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue comment information"))

        issues = Issue.objects.filter(
            external_reference=["bitbucket", bitbucket_url])
        tasks = Task.objects.filter(
            external_reference=["bitbucket", bitbucket_url])
        uss = UserStory.objects.filter(
            external_reference=["bitbucket", bitbucket_url])

        for item in list(issues) + list(tasks) + list(uss):
            if number and subject and bitbucket_user_name and bitbucket_user_url:
                comment = _(
                    "Comment by [@{bitbucket_user_name}]({bitbucket_user_url} "
                    "\"See @{bitbucket_user_name}'s BitBucket profile\") "
                    "from BitBucket.\nOrigin BitBucket issue: [bb#{number} - {subject}]({bitbucket_url} "
                    "\"Go to 'bb#{number} - {subject}'\")\n\n"
                    "{message}").format(
                        bitbucket_user_name=bitbucket_user_name,
                        bitbucket_user_url=bitbucket_user_url,
                        number=number,
                        subject=subject,
                        bitbucket_url=bitbucket_url,
                        message=comment_message)
            else:
                comment = _("Comment From BitBucket:\n\n{message}").format(
                    message=comment_message)

            snapshot = take_snapshot(item, comment=comment, user=user)
            send_notifications(item, history=snapshot)
Esempio n. 11
0
    def process_event(self):
        action = self.payload.get('action', None) 

        if action != "created" and action != "edited" and action != "deleted":
            raise ActionSyntaxException(_("Invalid issue comment information"))

        number = self.payload.get('issue', {}).get('number', None)
        subject = self.payload.get('issue', {}).get('title', None)
        github_url = self.payload.get('issue', {}).get('html_url', None)
        github_user_id = self.payload.get('sender', {}).get('id', None)
        github_user_name = self.payload.get('sender', {}).get('login', None)
        github_user_url = self.payload.get('sender', {}).get('html_url', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)
        comment_message = self.payload.get('comment', {}).get('body', None)
        comment_message = replace_github_references(project_url, comment_message)
        comment_github_url = self.payload.get('comment', {}).get('html_url', None)

        user = get_github_user(github_user_id)

        if not all([comment_message, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue comment information"))

        issues = Issue.objects.filter(external_reference=["github", github_url])
        tasks = Task.objects.filter(external_reference=["github", github_url])
        uss = UserStory.objects.filter(external_reference=["github", github_url])

        if number and subject and github_user_name and github_user_url:
            comment = _("Comment by [@{github_user_name}]({github_user_url} "
                        "\"See @{github_user_name}'s GitHub profile\") "
                        "from GitHub.\nOrigin GitHub comment: [gh#{number} - {subject}]({github_url} "
                        "\"Go to 'gh#{number} - {subject}'\")\n\n"
                        "{message}").format(github_user_name=github_user_name,
                                            github_user_url=github_user_url,
                                            number=number,
                                            subject=subject,
                                            github_url=comment_github_url,
                                            message=comment_message)
        else:
            comment = _("Comment From GitHub:\n\n{message}").format(message=comment_message)

        for item in list(issues) + list(tasks) + list(uss):
            if action == "created":
                self._process_created(item, comment, user)
            elif action == "edited":
                self._process_edited(item, comment, comment_github_url)
            elif action == "deleted":
                self._process_deleted(item, comment_github_url)
Esempio n. 12
0
    def _process_commit(self, ref, status_slug, commit):
        element = get_element_from_ref(self.project, ref)
        status = get_status_from_slug(self.project, element, status_slug)
        element.status = status
        element.save()

        commit_id = commit.get("id", None)
        commit_url = commit.get("url", None)
        # @todo replace_gitlab_references()?
        commit_message = commit.get("message").strip()
        author_info = self.get_user_info_from_payload(commit)
        author_user = author_info.get('user')

        """ Do we care about pushed by vs authored by?
        if author_info.get('email') != self.pusher.get('email'):
            if self.pusher.get('user') is not None:
                user = self.pusher.get('user')
                pushed_by = _(" (Pushed by @{pusher_username})").format(
                    pusher_username=user.get_username()
                )
            else:
                pushed_by = _(" (Pushed by [{pusher_username}](mailto:{pusher_url}))").format(
                    pusher_username=self.pusher.get('name'),
                    pusher_url=self.pusher.get('email')
                )
        else:
            pushed_by = ""
        """

        if not all([commit_id, commit_url]):
            raise ActionSyntaxException(_("Invalid commit information"))

        # we can use a real user
        if author_user is not None and not author_user.is_system:
            comment = _(self.messages.get('native').get('push')).format(
                username=author_user.username,
                service_type=self.service_type,
                status=status.name,
                commit_id=commit_id[:7],
                commit_url=commit_url,
                commit_message=commit_message)

        # use what info we have
        elif "name" in author_info and "email" in author_info:
            comment = _(self.messages.get('system').get('push')).format(
                name=author_info.get("name'"),
                service_type=self.service_type,
                status=status.name,
                user_url=author_info.get("url"),
                commit_id=str(commit_id)[:7],
                commit_url=commit_url,
                commit_message=commit_message)

        snapshot = take_snapshot(element,
                                 comment=comment,
                                 user=author_user)
        send_notifications(element, history=snapshot)
Esempio n. 13
0
def get_element_from_ref(project, ref):
    if Issue.objects.filter(project=project, ref=ref).exists():
        model_class = Issue
    elif Task.objects.filter(project=project, ref=ref).exists():
        model_class = Task
    elif UserStory.objects.filter(project=project, ref=ref).exists():
        model_class = UserStory
    else:
        raise ActionSyntaxException(_("The referenced element doesn't exist"))

    return model_class.objects.get(project=project, ref=ref)
Esempio n. 14
0
    def process_event(self):
        if self.payload.get('action', None) != "opened":
            return

        number = self.payload.get('issue', {}).get('number', None)
        subject = self.payload.get('issue', {}).get('title', None)
        github_url = self.payload.get('issue', {}).get('html_url', None)
        github_user_id = self.payload.get('issue', {}).get('user',
                                                           {}).get('id', None)
        github_user_name = self.payload.get('issue',
                                            {}).get('user',
                                                    {}).get('login', None)
        github_user_url = self.payload.get('issue',
                                           {}).get('user',
                                                   {}).get('html_url', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)
        description = self.payload.get('issue', {}).get('body', None)
        description = replace_github_references(project_url, description)

        user = get_github_user(github_user_id)

        if not all([subject, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(project=self.project,
                                     subject=subject,
                                     description=description,
                                     status=self.project.default_issue_status,
                                     type=self.project.default_issue_type,
                                     severity=self.project.default_severity,
                                     priority=self.project.default_priority,
                                     external_reference=['github', github_url],
                                     owner=user)
        take_snapshot(issue, user=user)

        if number and subject and github_user_name and github_user_url:
            comment = _(
                "Issue created by [@{github_user_name}]({github_user_url} "
                "\"See @{github_user_name}'s GitHub profile\") "
                "from GitHub.\nOrigin GitHub issue: [{number}: {subject}]({github_url} "
                "\"Go to '{number}: {subject}'\"):\n\n"
                "{description}").format(github_user_name=github_user_name,
                                        github_user_url=github_user_url,
                                        number=number,
                                        subject=subject,
                                        github_url=github_url,
                                        description=description)
        else:
            comment = _("Issue created from GitHub.")

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
Esempio n. 15
0
    def process_event(self):
        if self.payload.get('object_attributes', {}).get(
                "noteable_type", None) != "Issue":
            return

        number = self.payload.get('issue', {}).get('iid', None)
        subject = self.payload.get('issue', {}).get('title', None)

        project_url = self.payload.get('repository', {}).get('homepage', None)

        gitlab_url = os.path.join(project_url, "issues", str(number))
        gitlab_user_name = self.payload.get('user', {}).get('username', None)
        gitlab_user_url = os.path.join(
            os.path.dirname(os.path.dirname(project_url)), "u",
            gitlab_user_name)

        comment_message = self.payload.get('object_attributes',
                                           {}).get('note', None)
        comment_message = replace_gitlab_references(project_url,
                                                    comment_message)

        user = get_gitlab_user(None)

        if not all([comment_message, gitlab_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue comment information"))

        issues = Issue.objects.filter(
            external_reference=["gitlab", gitlab_url])
        tasks = Task.objects.filter(external_reference=["gitlab", gitlab_url])
        uss = UserStory.objects.filter(
            external_reference=["gitlab", gitlab_url])

        for item in list(issues) + list(tasks) + list(uss):
            if number and subject and gitlab_user_name and gitlab_user_url:
                comment = _(
                    "Comment by [@{gitlab_user_name}]({gitlab_user_url} "
                    "\"See @{gitlab_user_name}'s GitLab profile\") "
                    "from GitLab.\nOrigin GitLab issue: [gl#{number} - {subject}]({gitlab_url} "
                    "\"Go to 'gl#{number} - {subject}'\")\n\n"
                    "{message}").format(gitlab_user_name=gitlab_user_name,
                                        gitlab_user_url=gitlab_user_url,
                                        number=number,
                                        subject=subject,
                                        gitlab_url=gitlab_url,
                                        message=comment_message)
            else:
                comment = _("Comment From GitLab:\n\n{message}").format(
                    message=comment_message)

            snapshot = take_snapshot(item, comment=comment, user=user)
            send_notifications(item, history=snapshot)
Esempio n. 16
0
    def process_event(self):
        number = self.payload.get('issue', {}).get('id', None)
        subject = self.payload.get('issue', {}).get('title', None)

        bitbucket_url = self.payload.get('issue', {}).get('links', {}).get('html', {}).get('href', None)

        bitbucket_user_id = self.payload.get('actor', {}).get('user', {}).get('uuid', None)
        bitbucket_user_name = self.payload.get('actor', {}).get('user', {}).get('username', None)
        bitbucket_user_url = self.payload.get('actor', {}).get('user', {}).get('links', {}).get('html', {}).get('href')

        project_url = self.payload.get('repository', {}).get('links', {}).get('html', {}).get('href', None)

        description = self.payload.get('issue', {}).get('content', {}).get('raw', '')
        description = replace_bitbucket_references(project_url, description)

        user = get_bitbucket_user(bitbucket_user_id)

        if not all([subject, bitbucket_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=description,
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=['bitbucket', bitbucket_url],
            owner=user
        )
        take_snapshot(issue, user=user)

        if number and subject and bitbucket_user_name and bitbucket_user_url:
            comment = _("Issue created by [@{bitbucket_user_name}]({bitbucket_user_url} "
                        "\"See @{bitbucket_user_name}'s BitBucket profile\") "
                        "from BitBucket.\nOrigin BitBucket issue: [bb#{number} - {subject}]({bitbucket_url} "
                        "\"Go to 'bb#{number} - {subject}'\"):\n\n"
                        "{description}").format(bitbucket_user_name=bitbucket_user_name,
                                                bitbucket_user_url=bitbucket_user_url,
                                                number=number,
                                                subject=subject,
                                                bitbucket_url=bitbucket_url,
                                                description=description)
        else:
            comment = _("Issue created from BitBucket.")

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
Esempio n. 17
0
    def get_item_classes(self, ref):
        if Issue.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Issue
            statusClass = IssueStatus
        elif Task.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Task
            statusClass = TaskStatus
        elif UserStory.objects.filter(project=self.project, ref=ref).exists():
            modelClass = UserStory
            statusClass = UserStoryStatus
        else:
            raise ActionSyntaxException(
                _("The referenced element doesn't exist"))

        return (modelClass, statusClass)
Esempio n. 18
0
    def set_item_status(self, ref, status_slug):
        (modelClass, statusClass) = self.get_item_classes(ref)
        element = modelClass.objects.get(project=self.project, ref=ref)

        try:
            status = statusClass.objects.get(project=self.project, slug=status_slug)
        except statusClass.DoesNotExist:
            raise ActionSyntaxException(_("The status doesn't exist"))

        src_status = element.status.name
        dst_status = status.name

        element.status = status
        element.save()
        return (element, src_status, dst_status)
Esempio n. 19
0
    def process_event(self):
        if self.ignore():
            return

        data = self.get_data()

        if not all([data["subject"], data["url"]]):
            raise ActionSyntaxException(_("Invalid issue information"))

        if self.action_type == ISSUE_ACTION_CREATE:
            self._create_issue(data)
        elif self.action_type == ISSUE_ACTION_UPDATE:
            self._update_issue(data)
        elif self.action_type == ISSUE_ACTION_CLOSE:
            self._close_issue(data)
        elif self.action_type == ISSUE_ACTION_REOPEN:
            self._reopen_issue(data)
        elif self.action_type == ISSUE_ACTION_DELETE:
            self._delete_issue(data)
        else:
            raise NotImplementedError
Esempio n. 20
0
    def process_event(self):
        attrs = self.payload.get('object_attributes', {})

        if attrs.get("action", "") != "open":
            return

        subject = attrs.get('title', None)
        gitlab_reference = attrs.get('iid', None)
        gitlab_issue_url = attrs.get('url', None)
        gitlab_project_url = None
        user = self.user_info.get('user')

        if gitlab_issue_url:
            # the last two sections are always the "/issues/:id"
            gitlab_project_url = '/'.join(gitlab_issue_url.split('/')[:-2])

        description = replace_gitlab_references(gitlab_project_url, attrs.get('description', None))

        if not all([subject, gitlab_reference, gitlab_issue_url, gitlab_project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=replace_gitlab_references(gitlab_project_url, description),
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=['gitlab', gitlab_reference],
            owner=user
        )

        take_snapshot(issue, user=user)

        comment = _("Issue created from GitLab.")

        if user is not None and not user.is_system:
            comment = _(self.messages.get('native').get('issue')).format(
                username=user.username,
                service_type=self.service_type,
                remote_ref=gitlab_reference,
                subject=subject,
                remote_url=gitlab_issue_url,
                description=description
            )

        # use what info we have
        elif "name" in self.user_info and "email" in self.user_info:
            comment = _(self.messages.get('system').get('issue')).format(
                name=self.user_info.get("name'"),
                user_url=self.user_info.get('url'),
                service_type=self.service_type,
                remote_ref=gitlab_reference,
                subject=subject,
                remote_url=gitlab_issue_url,
                description=description
            )

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)