# create python virtual environment
python -m venv ghost
source ./ghost/bin/activate
pip install requests
python ./fix_github_ghost_notification.py
Created
March 7, 2024 04:03
-
-
Save akunzai/8b8f55a9244713742d83b6e65738f256 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import requests | |
from datetime import datetime, timezone | |
NOTIFICATIONS = 'https://api.github.com/notifications' | |
token = os.environ['GH_TOKEN'] | |
s = requests.Session() | |
s.headers.update({ | |
'Authorization': f'Bearer {token}', | |
'Accept': 'application/vnd.github+json'}) | |
r = s.get(NOTIFICATIONS) | |
print(json.dumps(r.json(), indent=2)) | |
now = datetime.now(timezone.utc) | |
print(now.isoformat(timespec='seconds')) | |
r = s.put( | |
NOTIFICATIONS, | |
json={ | |
'last_read_at': now.isoformat(timespec='seconds'), | |
'read': True | |
}) | |
print(r.status_code) | |
for k, v in r.headers.items(): | |
print(f'{k}: {v}') | |
print(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment