mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-10 18:21:34 +03:00
initial webhook reading for github
This commit is contained in:
parent
8a6b9b4b1a
commit
4a1420d301
100
ape/gh.hoon
100
ape/gh.hoon
@ -1,4 +1,5 @@
|
||||
/? 314
|
||||
/- gh
|
||||
=> |%
|
||||
++ move (pair bone card)
|
||||
++ sub-result
|
||||
@ -9,29 +10,49 @@
|
||||
[%them wire (unit hiss)]
|
||||
==
|
||||
--
|
||||
|_ [hid=bowl cnt=@ hook=(unit ,@t)]
|
||||
++ gh
|
||||
|_ [style=@tas pax=path]
|
||||
|_ [hid=bowl cnt=@ hook=(map ,@t ,[id=@t listeners=(set bone)])]
|
||||
::++ prep ,_`.
|
||||
++ help
|
||||
|= [style=@tas pax=path]
|
||||
=| mow=(list move)
|
||||
|%
|
||||
++ abet
|
||||
^- [(list move) _+>.$]
|
||||
[(flop mow) +>.$]
|
||||
++ real-pax (scan "https://api.github.com{<`path`pax>}" auri:epur)
|
||||
++ send-hiss
|
||||
|= h=hiss
|
||||
^+ +>
|
||||
+>.$(mow [[ost.hid %them [%x (scot %ud cnt) pax] ~ h] mow])
|
||||
++ auth
|
||||
['Authorization' 'Basic cGhpbGlwY21vbmt0ZXN0OjEzMzdwYXNzd29yZA==' ~]
|
||||
++ scry
|
||||
^- hiss
|
||||
^+ .
|
||||
=- ~& [%requesting -] -
|
||||
?+ style ~|(%invalid-style !!)
|
||||
%read-unauth read-unauth
|
||||
%read-auth read-auth
|
||||
%listen listen
|
||||
==
|
||||
++ read-unauth `hiss`[real-pax %get ~ ~]
|
||||
++ read-auth `hiss`[real-pax %get [auth ~ ~] ~]
|
||||
++ read-unauth (send-hiss real-pax %get ~ ~)
|
||||
++ read-auth (send-hiss real-pax %get [auth ~ ~] ~)
|
||||
++ listen
|
||||
^- hiss
|
||||
?~ hook
|
||||
create-hook
|
||||
update-hook
|
||||
^+ .
|
||||
?> ?=([@ @ *] pax)
|
||||
=+ xap=t.t.pax
|
||||
|- ^+ +>.$
|
||||
?~ xap
|
||||
+>.$
|
||||
?: (~(has by hook) i.xap)
|
||||
=. +>.$ =>((update-hook i.xap) ?>(?=([@ @ *] pax) .))
|
||||
$(xap t.xap)
|
||||
=. +>.$ =>((create-hook i.xap) ?>(?=([@ @ *] pax) .))
|
||||
$(xap t.xap)
|
||||
++ create-hook
|
||||
?> ?=([@ @ @ *] pax)
|
||||
|= event=@t
|
||||
^+ +>
|
||||
?> ?=([@ @ *] pax)
|
||||
%- send-hiss
|
||||
:* %+ scan
|
||||
=+ [(trip i.pax) (trip i.t.pax)]
|
||||
"https://api.github.com/repos/{-<}/{->}/hooks"
|
||||
@ -40,45 +61,70 @@
|
||||
%- taco %- crip %- pojo %- jobe :~
|
||||
name/s/%web
|
||||
active/b/&
|
||||
events/a/(turn `(list ,@t)`t.t.pax |=(a=@t s/a))
|
||||
events/a/~[s/event] ::(turn `(list ,@t)`t.t.pax |=(a=@t s/a))
|
||||
:- %config
|
||||
%- jobe :~
|
||||
[%url s/'http://107.170.195.5:8445/~/to/gh/json.json?anon&wire=/']
|
||||
=+ =+ `tape`(turn (trip event) |=(a=@tD ?:(=('_' a) '-' a)))
|
||||
"http://107.170.195.5:8445/~/to/gh/gh-{-}.json?anon&wire=/"
|
||||
[%url s/(crip -)]
|
||||
[%'content_type' s/%json]
|
||||
==
|
||||
==
|
||||
==
|
||||
++ update-hook
|
||||
|= event=@t
|
||||
^+ +>
|
||||
?> ?=([@ @ @ *] pax)
|
||||
:* %+ scan
|
||||
=+ [(trip i.pax) (trip i.t.pax)]
|
||||
"https://api.github.com/repos/{-<}/{->}/hooks/{(trip (need hook))}"
|
||||
auri:epur
|
||||
%post [auth ~ ~] ~
|
||||
%- taco %- crip %- pojo %- jobe :~
|
||||
[%'add_events' a/(turn `(list ,@t)`t.t.pax |=(a=@t s/a))]
|
||||
==
|
||||
=+ hok=(~(got by hook) event)
|
||||
%_ +>.$
|
||||
hook
|
||||
%+ ~(put by hook) event
|
||||
hok(listeners (~(put in listeners.hok) ost.hid))
|
||||
==
|
||||
:: :* %+ scan
|
||||
:: =+ [(trip i.pax) (trip i.t.pax)]
|
||||
:: "https://api.github.com/repos/{-<}/{->}/hooks/{(trip (need hook))}"
|
||||
:: auri:epur
|
||||
:: %post [auth ~ ~] ~
|
||||
:: %- taco %- crip %- pojo %- jobe :~
|
||||
:: [%'add_events' a/(turn `(list ,@t)`t.t.pax |=(a=@t s/a))]
|
||||
:: ==
|
||||
:: ==
|
||||
--
|
||||
::
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
^- [(list move) _+>.$]
|
||||
=+ ^- [repo=json sender=json hok=json hook-id=@t zen=json]
|
||||
~& %something
|
||||
=+ ^- [repo=json sender=json hok=(list ,@t) hook-id=@t zen=json]
|
||||
%- need
|
||||
%. jon
|
||||
=> jo
|
||||
(ot repository/some sender/some hook/some 'hook_id'^no zen/some ~)
|
||||
~& [%id hook-id]
|
||||
[~ +>.$(hook `hook-id)]
|
||||
(ot repository/some sender/some hook/(ot events/(ar so) ~) 'hook_id'^no zen/some ~)
|
||||
?. ?=([@ ~] hok)
|
||||
~& [%weird-hook hook-id hok]
|
||||
[~ +>.$]
|
||||
~& [%id hook-id hok]
|
||||
=+ old-bones=`(set bone)`(biff (~(get by hook) i.hok) tail)
|
||||
[~ +>.$(hook (~(put by hook) i.hok [hook-id (~(put in old-bones) ost.hid)]))]
|
||||
::
|
||||
++ poke-gh-issues
|
||||
|= issue=issues:gh
|
||||
^- [(list move) _+>.$]
|
||||
~& issue
|
||||
`+>.$
|
||||
++ peer-scry-x
|
||||
|= pax=path
|
||||
^- [(list move) _+>.$]
|
||||
:_ +>.$(cnt now.hid) :_ ~
|
||||
?> ?=(^ pax)
|
||||
=- ~& [%peered -] -
|
||||
[ost.hid %them [%x (scot %ud cnt) pax] ~ ~(scry gh i.pax t.pax)]
|
||||
[abet(cnt now.hid)]:scry:(help i.pax t.pax)
|
||||
::
|
||||
++ poke-gh-issue-comment
|
||||
|= comment=issue-comment:gh
|
||||
^- [(list move) _+>.$]
|
||||
~& comment
|
||||
`+>.$
|
||||
::
|
||||
++ thou-x
|
||||
|= [way=wire res=httr]
|
||||
|
143
lib/gh-parse.hoon
Normal file
143
lib/gh-parse.hoon
Normal file
@ -0,0 +1,143 @@
|
||||
/- gh
|
||||
|%
|
||||
++ repository
|
||||
^- $+(json (unit repository:gh))
|
||||
=+ jo
|
||||
%- ot :~
|
||||
'id'^id
|
||||
'name'^so
|
||||
'full_name'^so
|
||||
'owner'^user
|
||||
'private'^bo
|
||||
'html_url'^so
|
||||
'description'^so
|
||||
'fork'^bo
|
||||
'url'^so
|
||||
'forks_url'^so
|
||||
'keys_url'^so
|
||||
'collaborators_url'^so
|
||||
'teams_url'^so
|
||||
'hooks_url'^so
|
||||
'issue_events_url'^so
|
||||
'events_url'^so
|
||||
'assignees_url'^so
|
||||
'branches_url'^so
|
||||
'tags_url'^so
|
||||
'blobs_url'^so
|
||||
'git_tags_url'^so
|
||||
'git_refs_url'^so
|
||||
'trees_url'^so
|
||||
'statuses_url'^so
|
||||
'languages_url'^so
|
||||
'stargazers_url'^so
|
||||
'contributors_url'^so
|
||||
'subscribers_url'^so
|
||||
'subscription_url'^so
|
||||
'commits_url'^so
|
||||
'git_commits_url'^so
|
||||
'comments_url'^so
|
||||
'issue_comment_url'^so
|
||||
'contents_url'^so
|
||||
'compare_url'^so
|
||||
'merges_url'^so
|
||||
'archive_url'^so
|
||||
'downloads_url'^so
|
||||
'issues_url'^so
|
||||
'pulls_url'^so
|
||||
'milestones_url'^so
|
||||
'notifications_url'^so
|
||||
'labels_url'^so
|
||||
'releases_url'^so
|
||||
'created_at'^so
|
||||
'updated_at'^so
|
||||
'pushed_at'^so
|
||||
'git_url'^so
|
||||
'ssh_url'^so
|
||||
'clone_url'^so
|
||||
'svn_url'^so
|
||||
'homepage'^some
|
||||
'size'^ni
|
||||
'stargazers_count'^ni
|
||||
'watchers_count'^ni
|
||||
'language'^some
|
||||
'has_issues'^bo
|
||||
'has_downloads'^bo
|
||||
'has_wiki'^bo
|
||||
'has_pages'^bo
|
||||
'forks_count'^ni
|
||||
'mirror_url'^some
|
||||
'open_issues_count'^ni
|
||||
'forks'^ni
|
||||
'open_issues'^ni
|
||||
'watchers'^ni
|
||||
'default_branch'^so
|
||||
==
|
||||
++ user
|
||||
^- $+(json (unit user:gh))
|
||||
=+ jo
|
||||
%- ot :~
|
||||
'login'^so
|
||||
'id'^id
|
||||
'avatar_url'^so
|
||||
'gravatar_id'^so
|
||||
'url'^so
|
||||
'html_url'^so
|
||||
'followers_url'^so
|
||||
'following_url'^so
|
||||
'gists_url'^so
|
||||
'starred_url'^so
|
||||
'subscriptions_url'^so
|
||||
'organizations_url'^so
|
||||
'repos_url'^so
|
||||
'events_url'^so
|
||||
'received_events_url'^so
|
||||
'type'^so
|
||||
'site_admin'^bo
|
||||
==
|
||||
++ issue
|
||||
^- $+(json (unit issue:gh))
|
||||
=+ jo
|
||||
%- ot :~
|
||||
'url'^so
|
||||
'labels_url'^so
|
||||
'comments_url'^so
|
||||
'events_url'^so
|
||||
'html_url'^so
|
||||
'id'^id
|
||||
'number'^ni
|
||||
'title'^so
|
||||
'user'^user::|+(* (some *user:gh))
|
||||
'labels'^(ar label)::|+(* (some *(list label:gh)))::(ar label)
|
||||
'state'^so
|
||||
'locked'^bo
|
||||
'assignee'^(mu user)::|+(* (some *(unit user:gh)))::(mu user)
|
||||
'milestone'^some
|
||||
'comments'^ni
|
||||
'created_at'^so
|
||||
'updated_at'^so
|
||||
'closed_at'^(mu so)
|
||||
'body'^so
|
||||
==
|
||||
++ label
|
||||
^- $+(json (unit label:gh))
|
||||
=+ jo
|
||||
%- ot :~
|
||||
'url'^so
|
||||
'name'^so
|
||||
'color'^so
|
||||
==
|
||||
++ comment
|
||||
^- $+(json (unit comment:gh))
|
||||
=+ jo
|
||||
%- ot :~
|
||||
'url'^so
|
||||
'html_url'^so
|
||||
'issue_url'^so
|
||||
'id'^id
|
||||
'user'^user
|
||||
'created_at'^so
|
||||
'updated_at'^so
|
||||
'body'^so
|
||||
==
|
||||
++ id no:jo
|
||||
--
|
17
mar/gh/issue-comment.hoon
Normal file
17
mar/gh/issue-comment.hoon
Normal file
@ -0,0 +1,17 @@
|
||||
/- gh
|
||||
/+ gh-parse
|
||||
|_ issue-comment=issue-comment:gh
|
||||
++ grab
|
||||
|%
|
||||
++ json
|
||||
|= jon=^json
|
||||
^- issue-comment:gh
|
||||
=+ top=(need ((om:jo some) jon))
|
||||
:* (need (repository:gh-parse (~(got by top) %repository)))
|
||||
(need (user:gh-parse (~(got by top) %sender)))
|
||||
(need (so:jo (~(got by top) %action)))
|
||||
(need (issue:gh-parse (~(got by top) %issue)))
|
||||
(need (comment:gh-parse (~(got by top) %comment)))
|
||||
==
|
||||
--
|
||||
--
|
25
mar/gh/issues.hoon
Normal file
25
mar/gh/issues.hoon
Normal file
@ -0,0 +1,25 @@
|
||||
/- gh
|
||||
/+ gh-parse
|
||||
|_ issues=issues:gh
|
||||
++ grab
|
||||
|%
|
||||
++ json
|
||||
|= jon=^json
|
||||
^- issues:gh
|
||||
=+ top=(need ((om:jo some) jon))
|
||||
:* (need (repository:gh-parse (~(got by top) %repository)))
|
||||
(need (user:gh-parse (~(got by top) %sender)))
|
||||
=+ action=(need (so:jo (~(got by top) %action)))
|
||||
?+ action ~|([%bad-action action] !!)
|
||||
%assigned [action (need (user:gh-parse (~(got by top) %assignee)))]
|
||||
%unassigned [action (need (user:gh-parse (~(got by top) %assignee)))]
|
||||
%labeled [action (need (label:gh-parse (~(got by top) %label)))]
|
||||
%unlabeled [action (need (label:gh-parse (~(got by top) %label)))]
|
||||
%opened [action ~]
|
||||
%closed [action ~]
|
||||
%reopened [action ~]
|
||||
==
|
||||
(need (issue:gh-parse (~(got by top) %issue)))
|
||||
==
|
||||
--
|
||||
--
|
6
mar/path.hoon
Normal file
6
mar/path.hoon
Normal file
@ -0,0 +1,6 @@
|
||||
|_ pax=path
|
||||
++ grab
|
||||
|%
|
||||
++ noun path
|
||||
--
|
||||
--
|
150
sur/gh.hoon
Normal file
150
sur/gh.hoon
Normal file
@ -0,0 +1,150 @@
|
||||
|%
|
||||
++ repository
|
||||
$: id=id
|
||||
name=@t
|
||||
full-name=@t
|
||||
owner=user
|
||||
private=?
|
||||
html-url=@t
|
||||
description=@t
|
||||
fork=?
|
||||
url=@t
|
||||
forks-url=@t
|
||||
keys-url=@t
|
||||
collaborators-url=@t
|
||||
teams-url=@t
|
||||
hooks-url=@t
|
||||
issue-events-url=@t
|
||||
events-url=@t
|
||||
assignees-url=@t
|
||||
branches-url=@t
|
||||
tags-url=@t
|
||||
blobs-url=@t
|
||||
git-tags-url=@t
|
||||
git-refs-url=@t
|
||||
trees-url=@t
|
||||
statuses-url=@t
|
||||
languages-url=@t
|
||||
stargazers-url=@t
|
||||
contributors-url=@t
|
||||
subscribers-url=@t
|
||||
subscription-url=@t
|
||||
commits-url=@t
|
||||
git-commits-url=@t
|
||||
comments-url=@t
|
||||
issue-comment-url=@t
|
||||
contents-url=@t
|
||||
compare-url=@t
|
||||
merges-url=@t
|
||||
archive-url=@t
|
||||
downloads-url=@t
|
||||
issues-urls=@t
|
||||
pulls-url=@t
|
||||
milestones-url=@t
|
||||
notifications-url=@t
|
||||
labels-url=@t
|
||||
releases-url=@t
|
||||
created-at=time
|
||||
updated-at=time
|
||||
pushed-at=time
|
||||
git-url=@t
|
||||
ssh-url=@t
|
||||
clone-url=@t
|
||||
svn-url=@t
|
||||
homepage=json
|
||||
size=@ud
|
||||
stargazers-count=@ud
|
||||
watchers-count=@ud
|
||||
language=json
|
||||
has-issues=?
|
||||
has-downloads=?
|
||||
has-wiki=?
|
||||
has-pages=?
|
||||
forks-count=@ud
|
||||
mirror-url=json
|
||||
open-issues-count=@ud
|
||||
forks=@ud
|
||||
open-issues=@ud
|
||||
watchers=@ud
|
||||
default-branch=@t
|
||||
==
|
||||
++ user
|
||||
$: login=@t
|
||||
id=id
|
||||
avatar-url=@t
|
||||
gravatar-id=@t
|
||||
url=@t
|
||||
html-url=@t
|
||||
followers-url=@t
|
||||
following-url=@t
|
||||
gists-url=@t
|
||||
starred-url=@t
|
||||
subscriptions-url=@t
|
||||
organizations-url=@t
|
||||
repos-url=@t
|
||||
events-url=@t
|
||||
received-events=@t
|
||||
type=@t
|
||||
site-admin=?
|
||||
==
|
||||
++ issue
|
||||
$: url=@t
|
||||
labels-url=@t
|
||||
comments-url=@t
|
||||
events-url=@t
|
||||
html-url=@t
|
||||
id=id
|
||||
number=@ud
|
||||
title=@t
|
||||
user=user
|
||||
labels=(list label)
|
||||
state=@t
|
||||
locked=?
|
||||
assignee=(unit user)
|
||||
milestone=json
|
||||
comments=@ud
|
||||
created-at=time
|
||||
updated-at=time
|
||||
closed-at=(unit time)
|
||||
body=@t
|
||||
==
|
||||
++ label
|
||||
$: url=@t
|
||||
name=@t
|
||||
color=@t
|
||||
==
|
||||
++ comment
|
||||
$: url=@t
|
||||
html-url=@t
|
||||
issue-url=@t
|
||||
id=id
|
||||
user=user
|
||||
created-at=time
|
||||
updated-at=time
|
||||
body=@t
|
||||
==
|
||||
++ id ,@t
|
||||
++ time ,@t
|
||||
++ issues
|
||||
$: repository=repository
|
||||
sender=user
|
||||
$= action
|
||||
$% [%assigned assignee=user]
|
||||
[%unassigned assignee=user]
|
||||
[%labeled label=label]
|
||||
[%unlabeled label=label]
|
||||
[%opened ~]
|
||||
[%closed ~]
|
||||
[%reopened ~]
|
||||
==
|
||||
issue=issue
|
||||
==
|
||||
++ issue-comment
|
||||
$: repository=repository
|
||||
sender=user
|
||||
action=@t
|
||||
issue=issue
|
||||
comment=comment
|
||||
==
|
||||
++ ping ,[repo=json sender=json hok=(list ,@t) hook-id=@t zen=json]
|
||||
--
|
Loading…
Reference in New Issue
Block a user