Skip to content

Commit 04cdeb6

Browse files
committed
feat: implement connect tab interactions
1 parent 41c58e6 commit 04cdeb6

5 files changed

Lines changed: 423 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ services:
3131
### This is not (and probably won't be for a while) a 100% accurate recreation of the twitter API
3232
3333
most of this readme todo
34+
35+
## Thanks
36+
@Preloading - I wrote the thing
37+
@Safefade - Gave me info on some of the requests

bluesky/blueskyapi.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,24 @@ type TrendingTopic struct {
286286
Link string `json:"link"`
287287
}
288288

289+
type Notification struct {
290+
URI string `json:"uri"`
291+
CID string `json:"cid"`
292+
Author User `json:"author"`
293+
Reason string `json:"reason"`
294+
ReasonSubject string `json:"reasonSubject"`
295+
Record PostInteractionRecord `json:"record"` // i think this is the correct object?
296+
IsRead bool `json:"isRead"`
297+
IndexedAt time.Time `json:"indexedAt"`
298+
}
299+
300+
type Notifications struct {
301+
Notifications []Notification `json:"notifications"`
302+
Cursor string `json:"cursor"`
303+
Priority bool `json:"priority"`
304+
SeenAt time.Time `json:"seenAt"`
305+
}
306+
289307
var (
290308
configData *config.Config
291309
)
@@ -1350,6 +1368,39 @@ func GetOthersSuggestedUsers(pds string, token string, limit int, actor string)
13501368
return users.Actors, nil
13511369
}
13521370

1371+
func GetNotifications(pds string, token string, limit int, context string) (*Notifications, error) {
1372+
url := pds + "/xrpc/app.bsky.notification.listNotifications?limit=" + fmt.Sprintf("%d", limit)
1373+
if context != "" {
1374+
url = pds + "/xrpc/app.bsky.notification.listNotifications?cursor=" + context + "&limit=" + fmt.Sprintf("%d", limit)
1375+
}
1376+
1377+
resp, err := SendRequest(&token, http.MethodGet, url, nil)
1378+
if err != nil {
1379+
return nil, err
1380+
}
1381+
defer resp.Body.Close()
1382+
1383+
// // Print the response body for debugging
1384+
// bodyBytes, _ := io.ReadAll(resp.Body)
1385+
// bodyString := string(bodyBytes)
1386+
// fmt.Println("Response Body:", bodyString)
1387+
1388+
if resp.StatusCode != http.StatusOK {
1389+
bodyBytes, _ := io.ReadAll(resp.Body)
1390+
bodyString := string(bodyBytes)
1391+
fmt.Println("Response Status:", resp.StatusCode)
1392+
fmt.Println("Response Body:", bodyString)
1393+
return nil, errors.New("failed to fetch notifications")
1394+
}
1395+
1396+
notifications := Notifications{}
1397+
if err := json.NewDecoder(resp.Body).Decode(&notifications); err != nil {
1398+
return nil, err
1399+
}
1400+
1401+
return &notifications, nil
1402+
}
1403+
13531404
// Gets the URI components
13541405
//
13551406
// @param uri: The URI to ge split

bridge/bridge.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ type UserRelationships struct {
233233
Relationships []UsersRelationship `json:"relationship" xml:"relationship"`
234234
}
235235

236+
// Currently known how it forms follows, but we are missing favourites etc
237+
type MyActivity struct {
238+
Action string `json:"action" xml:"action"`
239+
CreatedAt string `json:"created_at" xml:"created_at"`
240+
ID *big.Int `json:"id" xml:"id"`
241+
Sources []TwitterUser `json:"sources" xml:"sources"`
242+
Targets []Tweet `json:"targets,omitempty" xml:"targets,omitempty"`
243+
TargetObjects []Tweet `json:"target_objects,omitempty" xml:"target_objects,omitempty"`
244+
}
245+
236246
// https://web.archive.org/web/20120516154953/https://dev.twitter.com/docs/api/1/get/friendships/show
237247
// used in the /friendships/show endpoint
238248
type UserFriendship struct {

0 commit comments

Comments
 (0)