mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
Mark notification as read (#932)
Wraps the parts of the notification API that allows the user to mark notifications as read. New methods are : - Notification.mark_as_read : marks a single notification thread as read - Repository.mark_notifications_as_read : marks all the notifications for a given repository as read - AuthenticatedUser.mark_notifications_as_read : marks all the notifications as read Aims to fix : https://github.com/PyGithub/PyGithub/issues/571 and simply uses the APIs described on this page : https://developer.github.com/enterprise/11.10.340/v3/activity/notifications/ A weird thing I noticed doing this is that Repository.notifications_url doesn't seem to be usable directly. I used Repository.url + "/notifications" instead.
This commit is contained in:
committed by
Wan Liuyang
parent
2b2ecfad4d
commit
0a10d7cdf0
@@ -2473,6 +2473,22 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
for element in data["issues"]
|
||||
]
|
||||
|
||||
def mark_notifications_as_read(self, last_read_at=datetime.datetime.utcnow()):
|
||||
"""
|
||||
:calls: `PUT /repos/:owner/:repo/notifications <https://developer.github.com/v3/activity/notifications>`_
|
||||
:param last_read_at: datetime
|
||||
"""
|
||||
assert isinstance(last_read_at, datetime.datetime)
|
||||
put_parameters = {
|
||||
"last_read_at": last_read_at.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
}
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/notifications",
|
||||
input=put_parameters
|
||||
)
|
||||
|
||||
def merge(self, base, head, commit_message=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/merges <http://developer.github.com/v3/repos/merging>`_
|
||||
|
||||
Reference in New Issue
Block a user