Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getNotifications #511

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions src/GitHub/Data/Activities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ instance FromJSON RepoStarred where

data Subject = Subject
{ subjectTitle :: !Text
, subjectURL :: !URL
, subjectURL :: !(Maybe URL)
, subjectLatestCommentURL :: !(Maybe URL)
-- https://developer.github.com/v3/activity/notifications/ doesn't indicate
-- what the possible values for this field are.
Expand All @@ -46,13 +46,18 @@ instance FromJSON Subject where
<*> o .: "type"

data NotificationReason
= AssignReason
= ApprovalRequestedReason
| AssignReason
| AuthorReason
| CommentReason
| CiActivityReason
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I am not 100% if this is the correct capitalisation, but CIActivity looked fishy. ;-)

| InvitationReason
| ManualReason
| MemberFeatureRequestedReason
| MentionReason
| ReviewRequestedReason
| SecurityAlertReason
| SecurityAdvisoryCreditReason
| StateChangeReason
| SubscribedReason
| TeamMentionReason
Expand All @@ -63,17 +68,22 @@ instance Binary NotificationReason

instance FromJSON NotificationReason where
parseJSON = withText "NotificationReason" $ \t -> case T.toLower t of
"assign" -> pure AssignReason
"author" -> pure AuthorReason
"comment" -> pure CommentReason
"invitation" -> pure InvitationReason
"manual" -> pure ManualReason
"mention" -> pure MentionReason
"review_requested" -> pure ReviewRequestedReason
"state_change" -> pure StateChangeReason
"subscribed" -> pure SubscribedReason
"team_mention" -> pure TeamMentionReason
_ -> fail $ "Unknown NotificationReason " ++ show t
"approval_requested" -> pure ApprovalRequestedReason
"assign" -> pure AssignReason
"author" -> pure AuthorReason
"comment" -> pure CommentReason
"ci_activity" -> pure CiActivityReason
"invitation" -> pure InvitationReason
"manual" -> pure ManualReason
"member_feature_requested" -> pure MemberFeatureRequestedReason
"mention" -> pure MentionReason
"review_requested" -> pure ReviewRequestedReason
"security_alert" -> pure SecurityAlertReason
"security_advisory_credit" -> pure SecurityAdvisoryCreditReason
"state_change" -> pure StateChangeReason
"subscribed" -> pure SubscribedReason
"team_mention" -> pure TeamMentionReason
_ -> fail $ "Unknown NotificationReason " ++ show t

data Notification = Notification
-- XXX: The notification id field type IS in fact string. Not sure why gh
Expand Down
Loading