Пример #1
0
    def _fillwith_notifMessages(self, notifMessages):
        repo_ids = [x.repo_id for x in notifMessages]
        userprofile_ids = [x.user_id for x in notifMessages]
        repo_dict = dict(
            (x.id, x) for x in RepoManager.list_repo_by_ids(repo_ids))
        userprofile_dict = dict(
            (x.id, x)
            for x in GsuserManager.list_userprofile_by_ids(userprofile_ids))
        for notifMessage in notifMessages:
            if notifMessage.repo_id in repo_dict:
                notifMessage.repo = repo_dict[notifMessage.repo_id]
            if notifMessage.from_user_id in userprofile_dict:
                notifMessage.from_userprofile = userprofile_dict[
                    notifMessage.from_user_id]

            if notifMessage.is_at_commit():
                commitHistory = RepoManager.get_commit_by_id(
                    notifMessage.relative_id)
                notifMessage.relative_obj = commitHistory
            elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
                issue = IssueManager.get_issue_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = issue
            elif notifMessage.is_at_merge(
            ) or notifMessage.is_pull_request_cate():
                pullRequest = RepoManager.get_pullRequest_by_id(
                    notifMessage.relative_id)
                notifMessage.relative_obj = pullRequest
            elif notifMessage.is_at_issue_comment():
                issue_comment = IssueManager.get_issue_comment(
                    notifMessage.relative_id)
                notifMessage.relative_obj = issue_comment
        return notifMessages
Пример #2
0
def _fillwith_pull_event(request, feeds):
    for feed in feeds:
        if not feed.is_pull_event():
            continue
        pullRequest = RepoManager.get_pullRequest_by_id(feed.relative_id)
        if pullRequest is None or pullRequest.source_repo is None or pullRequest.desc_repo is None:
            continue
        feed.relative_obj = pullRequest
Пример #3
0
 def create(self, notif_cate, notif_type, from_user_id, to_user_id,
            relative_id):
     notifMessage = NotifMessage(
         notif_cate=notif_cate,
         notif_type=notif_type,
         from_user_id=from_user_id,
         to_user_id=to_user_id,
         relative_id=relative_id,
     )
     if not relative_id:
         return notifMessage
     # without AT_MERGE_COMMENT
     if notifMessage.is_at_commit():
         commitHistory = RepoManager.get_commit_by_id(relative_id)
         if commitHistory:
             repo = RepoManager.get_repo_by_id(commitHistory.repo_id)
             if repo:
                 notifMessage.user_id = repo.user_id
                 notifMessage.repo_id = repo.id
     elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
         issue = IssueManager.get_issue_by_id(relative_id)
         if issue:
             notifMessage.user_id = issue.user_id
             notifMessage.repo_id = issue.repo_id
     elif notifMessage.is_at_merge() or notifMessage.is_pull_request_cate():
         pullRequest = RepoManager.get_pullRequest_by_id(relative_id)
         if pullRequest:
             repo = RepoManager.get_repo_by_id(pullRequest.desc_repo_id)
             if repo:
                 notifMessage.user_id = repo.user_id
                 notifMessage.repo_id = repo.id
     elif notifMessage.is_at_issue_comment():
         issue_comment = IssueManager.get_issue_comment(relative_id)
         if issue_comment:
             issue = IssueManager.get_issue_by_id(issue_comment.issue_id)
             if issue:
                 notifMessage.user_id = issue.user_id
                 notifMessage.repo_id = issue.repo_id
     return notifMessage
Пример #4
0
 def create(self, notif_cate, notif_type, from_user_id, to_user_id, relative_id):
     notifMessage = NotifMessage(
         notif_cate = notif_cate,
         notif_type = notif_type,
         from_user_id = from_user_id,
         to_user_id = to_user_id,
         relative_id = relative_id,
     )
     if not relative_id:
         return notifMessage
     # without AT_MERGE_COMMENT
     if notifMessage.is_at_commit():
         commitHistory = RepoManager.get_commit_by_id(relative_id)
         if commitHistory:
             repo = RepoManager.get_repo_by_id(commitHistory.repo_id)
             if repo:
                 notifMessage.user_id = repo.user_id
                 notifMessage.repo_id = repo.id
     elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
         issue = IssueManager.get_issue_by_id(relative_id)
         if issue:
             notifMessage.user_id = issue.user_id
             notifMessage.repo_id = issue.repo_id
     elif notifMessage.is_at_merge() or notifMessage.is_pull_request_cate():
         pullRequest = RepoManager.get_pullRequest_by_id(relative_id)
         if pullRequest:
             repo = RepoManager.get_repo_by_id(pullRequest.desc_repo_id)
             if repo:
                 notifMessage.user_id = repo.user_id
                 notifMessage.repo_id = repo.id
     elif notifMessage.is_at_issue_comment():
         issue_comment = IssueManager.get_issue_comment(relative_id)
         if issue_comment:
             issue = IssueManager.get_issue_by_id(issue_comment.issue_id)
             if issue:
                 notifMessage.user_id = issue.user_id
                 notifMessage.repo_id = issue.repo_id
     return notifMessage
Пример #5
0
    def _fillwith_notifMessages(self, notifMessages):
        repo_ids = [x.repo_id for x in notifMessages]
        userprofile_ids = [x.user_id for x in notifMessages]
        repo_dict = dict((x.id, x) for x in RepoManager.list_repo_by_ids(repo_ids))
        userprofile_dict = dict((x.id, x) for x in GsuserManager.list_userprofile_by_ids(userprofile_ids))
        for notifMessage in notifMessages:
            if notifMessage.repo_id in repo_dict:
                notifMessage.repo = repo_dict[notifMessage.repo_id]
            if notifMessage.from_user_id in userprofile_dict:
                notifMessage.from_userprofile = userprofile_dict[notifMessage.from_user_id]

            if notifMessage.is_at_commit():
                commitHistory = RepoManager.get_commit_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = commitHistory
            elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
                issue = IssueManager.get_issue_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = issue
            elif notifMessage.is_at_merge() or notifMessage.is_pull_request_cate():
                pullRequest = RepoManager.get_pullRequest_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = pullRequest
            elif notifMessage.is_at_issue_comment():
                issue_comment = IssueManager.get_issue_comment(notifMessage.relative_id)
                notifMessage.relative_obj = issue_comment
        return notifMessages