Skip to content

Latest commit

 

History

History
223 lines (200 loc) · 4.27 KB

WEBHOOKS.adoc

File metadata and controls

223 lines (200 loc) · 4.27 KB

WebHooks

Codebrag supports webhooks which can be used to notify external systems about all internal events.

Configuration

Just define the hooks section in your application.conf file based on the below example. These are the supported hooks:

  • like-hook - occurs when a user likes a given change

  • unlike-hook - occurs if a user dislikes the previously liked change

  • comment-added-hook - occurs when a user post a comment

  • commit-reviewed-hook - occurs when a user hit Reviewed button

  • all-commits-reviewed-hook - occurs when a user hit a button and marked all commits to be reviewed as reviewed at once in current repo for current branch

  • new-commits-loaded-hook - occurs after loading by Codebrag new commits from repo

  • new-user-registered-hook - occurs on registering a new user in the system

You can define multiple listeners for every hook, just separate urls by comma

Example configuration

hooks {
    like-hook = ["https://localhost:8000/", "https://some.other.host:9898/"]
    unlike-hook = ["https://localhost:8000/"]
}

Format

Right now Codebrag sends hooks as JSON encoded as UTF-8, below is the list of formats for each hook:

like-hook

{
  "commitInfo": {
    "repoName": string,
    "sha": string,
    "message": string,
    "authorName": string,
    "authorEmail": string,
    "committerName": string,
    "committerEmail": string,
    "authorDate": date,
    "commitDate": date,
    "parents": [string, string]
  },
  "likedBy": {
    "name": string,
    "emailLowerCase": string,
    "aliases": [{
      "alias": string
    }]
  },
  "like": {
    "postingTime": date,
    "fileName": string,
    "lineNumber": int
  },
  "hookName": "like-hook",
  "hookDate": date
}

unlike-hook

{
  "commitInfo": {
    "repoName": string,
    "sha": string,
    "message": string,
    "authorName": string,
    "authorEmail": string,
    "committerName": string,
    "committerEmail": string,
    "authorDate": date,
    "commitDate": date,
    "parents": [string, string]
  },
  "unlikedBy": {
    "name": string,
    "emailLowerCase": string,
    "aliases": [{
      "alias": string
    }]
  },
  "like": {
    "postingTime": date,
    "fileName": string,
    "lineNumber": int
  },
  "hookName": "unlike-hook",
  "hookDate": date
}

comment-added-hook

{
  "commitInfo": {
    "repoName": string,
    "sha": string,
    "message": string,
    "authorName": string,
    "authorEmail": string,
    "committerName": string,
    "committerEmail": string,
    "authorDate": date,
    "commitDate": date,
    "parents": [string, string]
  },
  "commentedBy": {
    "name": string,
    "emailLowerCase": string,
    "aliases": [{
      "alias": string
    }]
  },
  "comment": {
    "message": string,
    "postingTime": date,
    "fileName": string,
    "lineNumber": int
  },
  "hookName": "comment-added-hook",
  "hookDate": date
}

commit-reviewed-hook

{
  "commitInfo": {
    "repoName": string,
    "sha": string,
    "message": string,
    "authorName": string,
    "authorEmail": string,
    "committerName": string,
    "committerEmail": string,
    "authorDate": date,
    "commitDate": date,
    "parents": [string, string]
  },
  "reviewedBy": {
    "name": string,
    "emailLowerCase": string,
    "aliases": [{
      "alias": string
    }]
  },
  "hookName": "commit-reviewed-hook",
  "hookDate": date
}

all-commits-reviewed-hook

{
  "repoName": string,
  "branchName": string,
  "reviewedBy": {
    "name": string,
    "emailLowerCase": string,
    "aliases": [{
      "alias": string
    }]
  },
  "hookName": "all-commitc-reviewed-hook",
  "hookDate": date
}

comment-added-hook

{
  "repoName": string,
  "currentSHA": string,
  "newCommits": [
    {
      "sha": string,
      "message": string,
      "authorName": string,
      "authorEmail": string,
      "date": date
    }
  ],
  "hookName": "new-commits-loaded-hook",
  "hookDate": date
}

new-user-registered-hook

{
  "newUser": {
    "name": string,
    "emailLowerCase": string,
    "aliases": [{
      "alias": string
    }]
  },
  "login": string,
  "fullName": string,
  "hookName": "new-user-registered-hook",
  "hookDate": date
}