Skip to content

Commit

Permalink
ignore edite from gihtub app, #14
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed Mar 12, 2018
1 parent 8720922 commit b0ade8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

config :app, :github_app_name, Map.fetch!(System.get_env(), "GITHUB_APP_NAME")

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
8 changes: 5 additions & 3 deletions lib/app_web/controllers/event_type_handlers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule AppWeb.EventTypeHandlers do
alias AppWeb.MetaTable

@github_api Application.get_env(:app, :github_api)
@github_app_name Application.get_env(:app, :github_app_name)
@s3_api Application.get_env(:app, :s3_api)

@moduledoc """
Expand Down Expand Up @@ -50,7 +51,7 @@ defmodule AppWeb.EventTypeHandlers do
repo_name = payload["repository"]["full_name"]
issue_number = payload["issue"]["number"]
token = @github_api.get_installation_token(payload["installation"]["id"])
@github_api.add_meta_table(repo_name, issue_number, content, token) |> IO.inspect
@github_api.add_meta_table(repo_name, issue_number, content, token)

conn
|> put_status(200)
Expand All @@ -59,13 +60,14 @@ defmodule AppWeb.EventTypeHandlers do

def issue_edited(conn, payload) do
issue_id = payload["issue"]["id"]

if Map.has_key?(payload["changes"], "title") do
issue = Repo.get_by!(Issue, issue_id: issue_id)
issue = Changeset.change issue, title: payload["issue"]["title"]
Repo.update!(issue)
end

if Map.has_key?(payload["changes"], "body") do
if body_change && not_bot do
comment = payload["issue"]["body"]
author = payload["sender"]["login"]
add_comment_version(issue_id, "#{issue_id}_1", comment, author)
Expand Down

0 comments on commit b0ade8e

Please sign in to comment.