Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3749373
D530.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D530.diff
View Options
diff --git a/app/Analyzers/GitHub/Events/WatchEvent.php b/app/Analyzers/GitHub/Events/WatchEvent.php
new file mode 100644
--- /dev/null
+++ b/app/Analyzers/GitHub/Events/WatchEvent.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Nasqueron\Notifications\Analyzers\GitHub\Events;
+
+/**
+ * WatchEvent payload analyzer
+ *
+ * Triggered when an user stars a repository.
+ *
+ * The current starring action on GitHub is the old watch action. To avoid
+ * to break code, former event name have been kept in the API.
+ *
+ * @link https://developer.github.com/changes/2012-09-05-watcher-api/
+ * @link https://developer.github.com/v3/activity/events/types/#watchevent
+ */
+class WatchEvent extends Event {
+
+ /**
+ * Gets description for the payload
+ *
+ * @return string
+ */
+ public function getDescription () {
+ return trans(
+ 'GitHub.EventsDescriptions.WatchEvent',
+ [
+ 'user' => $this->payload->sender->login,
+ 'repository' => $this->payload->repository->full_name,
+ ]
+ );
+ }
+
+ /**
+ * Gets link for the payload
+ *
+ * @return string
+ */
+ public function getLink () {
+ return $this->payload->sender->html_url;
+ }
+}
diff --git a/resources/lang/en/GitHub.php b/resources/lang/en/GitHub.php
--- a/resources/lang/en/GitHub.php
+++ b/resources/lang/en/GitHub.php
@@ -43,6 +43,8 @@
'RepositoryEventFork' => ' (fork)',
'StatusEvent' => 'Status of :commit: :status',
+
+ 'WatchEvent' => ':user starred :repository',
],
'StatusEventState' => [
diff --git a/tests/Analyzers/GitHub/Events/EventTest.php b/tests/Analyzers/GitHub/Events/EventTest.php
--- a/tests/Analyzers/GitHub/Events/EventTest.php
+++ b/tests/Analyzers/GitHub/Events/EventTest.php
@@ -87,6 +87,11 @@
'Status of 9049f126: default — success',
''
],
+ 'WatchEvent' => [
+ 'watch',
+ 'baxterthehacker starred baxterthehacker/public-repo',
+ 'https://github.com/baxterthehacker'
+ ],
];
}
diff --git a/tests/data/payloads/GitHubEvents/watch.json b/tests/data/payloads/GitHubEvents/watch.json
new file mode 100644
--- /dev/null
+++ b/tests/data/payloads/GitHubEvents/watch.json
@@ -0,0 +1,109 @@
+{
+ "action": "started",
+ "repository": {
+ "id": 35129377,
+ "name": "public-repo",
+ "full_name": "baxterthehacker/public-repo",
+ "owner": {
+ "login": "baxterthehacker",
+ "id": 6752317,
+ "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/baxterthehacker",
+ "html_url": "https://github.com/baxterthehacker",
+ "followers_url": "https://api.github.com/users/baxterthehacker/followers",
+ "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
+ "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
+ "organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
+ "repos_url": "https://api.github.com/users/baxterthehacker/repos",
+ "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
+ "type": "User",
+ "site_admin": false
+ },
+ "private": false,
+ "html_url": "https://github.com/baxterthehacker/public-repo",
+ "description": "",
+ "fork": false,
+ "url": "https://api.github.com/repos/baxterthehacker/public-repo",
+ "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
+ "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
+ "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
+ "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
+ "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
+ "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
+ "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
+ "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
+ "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
+ "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
+ "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
+ "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
+ "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
+ "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
+ "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
+ "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
+ "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
+ "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
+ "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
+ "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
+ "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
+ "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
+ "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
+ "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
+ "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
+ "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
+ "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
+ "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
+ "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
+ "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
+ "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
+ "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
+ "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
+ "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
+ "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
+ "created_at": "2015-05-05T23:40:12Z",
+ "updated_at": "2015-05-05T23:40:30Z",
+ "pushed_at": "2015-05-05T23:40:27Z",
+ "git_url": "git://github.com/baxterthehacker/public-repo.git",
+ "ssh_url": "git@github.com:baxterthehacker/public-repo.git",
+ "clone_url": "https://github.com/baxterthehacker/public-repo.git",
+ "svn_url": "https://github.com/baxterthehacker/public-repo",
+ "homepage": null,
+ "size": 0,
+ "stargazers_count": 0,
+ "watchers_count": 0,
+ "language": null,
+ "has_issues": true,
+ "has_downloads": true,
+ "has_wiki": true,
+ "has_pages": true,
+ "forks_count": 0,
+ "mirror_url": null,
+ "open_issues_count": 2,
+ "forks": 0,
+ "open_issues": 2,
+ "watchers": 0,
+ "default_branch": "master"
+ },
+ "sender": {
+ "login": "baxterthehacker",
+ "id": 6752317,
+ "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/baxterthehacker",
+ "html_url": "https://github.com/baxterthehacker",
+ "followers_url": "https://api.github.com/users/baxterthehacker/followers",
+ "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
+ "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
+ "organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
+ "repos_url": "https://api.github.com/users/baxterthehacker/repos",
+ "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
+ "type": "User",
+ "site_admin": false
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 14:50 (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2249512
Default Alt Text
D530.diff (8 KB)
Attached To
Mode
D530: Handle watch event (star) on GitHub
Attached
Detach File
Event Timeline
Log In to Comment