Skip to content

Commit 83a258a

Browse files
committed
actually make it check friendship status
1 parent bcf3f15 commit 83a258a

3 files changed

Lines changed: 26 additions & 15 deletions

File tree

bluesky/blueskyapi.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type User struct {
4545
StarterPacks int `json:"starterPacks"`
4646
Labeler bool `json:"labeler"`
4747
CreatedAt time.Time `json:"created_at"`
48-
}
48+
} `json:"associated"`
4949
Viewer struct {
5050
Muted bool `json:"muted"`
5151
// MutedByList
@@ -55,7 +55,7 @@ type User struct {
5555
Following *string `json:"following,omitempty"`
5656
FollowedBy *string `json:"followedBy,omitempty"`
5757
// KnownFollowers
58-
}
58+
} `json:"viewer"`
5959
}
6060

6161
type PostRecord struct {
@@ -334,7 +334,7 @@ func GetUserInfo(token string, screen_name string) (*bridge.TwitterUser, error)
334334
return &user, nil
335335
}
336336

337-
url := "https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile" + "?actor=" + screen_name
337+
url := "https://bsky.social/xrpc/app.bsky.actor.getProfile" + "?actor=" + screen_name
338338

339339
resp, err := SendRequest(&token, http.MethodGet, url, nil)
340340
if err != nil {
@@ -395,7 +395,7 @@ func GetUsersInfo(token string, items []string, ignoreCache bool) ([]*bridge.Twi
395395
go func(c []string) {
396396
defer wg.Done()
397397

398-
url := "https://public.api.bsky.app/xrpc/app.bsky.actor.getProfiles" + "?actors=" + strings.Join(c, "&actors=")
398+
url := "https://bsky.social/xrpc/app.bsky.actor.getProfiles" + "?actors=" + strings.Join(c, "&actors=")
399399
resp, err := SendRequest(&token, http.MethodGet, url, nil)
400400
if err != nil {
401401
fmt.Println(err)
@@ -451,7 +451,7 @@ func GetUsersInfoRaw(token string, items []string, ignoreCache bool) ([]*User, e
451451
go func(c []string) {
452452
defer wg.Done()
453453

454-
url := "https://public.api.bsky.app/xrpc/app.bsky.actor.getProfiles" + "?actors=" + strings.Join(c, "&actors=")
454+
url := "https://bsky.social/xrpc/app.bsky.actor.getProfiles" + "?actors=" + strings.Join(c, "&actors=")
455455
fmt.Println(url)
456456
resp, err := SendRequest(&token, http.MethodGet, url, nil)
457457
if err != nil {

bridge/bridge.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,21 @@ type Config struct {
206206
}
207207

208208
type UserRelationship struct {
209-
Name string `json:"name" xml:"name"`
210-
IDStr string `json:"id_str" xml:"id_str"`
211-
ID big.Int `json:"id" xml:"id"`
212-
Connections []string `json:"connections" xml:"connections"`
213-
ScreenName string `json:"screen_name" xml:"screen_name"`
209+
Name string `json:"name" xml:"name"`
210+
IDStr string `json:"id_str" xml:"id_str"`
211+
ID big.Int `json:"id" xml:"id"`
212+
Connections Connections `json:"connections" xml:"connections"`
213+
ScreenName string `json:"screen_name" xml:"screen_name"`
214+
}
215+
216+
type Connection struct {
217+
XMLName xml.Name `xml:"connection"`
218+
Value string `xml:",chardata"`
219+
}
220+
221+
type Connections struct {
222+
XMLName xml.Name `xml:"connections"`
223+
Connection []Connection `xml:"connection"`
214224
}
215225

216226
type UserRelationships struct {

twitterv1/user.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,19 @@ func UserRelationships(c *fiber.Ctx) error {
130130
return c.Status(fiber.StatusInternalServerError).SendString("Failed to encode user id")
131131
}
132132

133-
connections := []string{}
133+
connections := bridge.Connections{}
134+
134135
if user.Viewer.Following != nil {
135-
connections = append(connections, "following")
136+
connections.Connection = append(connections.Connection, bridge.Connection{Value: "following"})
136137
}
137138
if user.Viewer.FollowedBy != nil {
138-
connections = append(connections, "followed_by")
139+
connections.Connection = append(connections.Connection, bridge.Connection{Value: "followed_by"})
139140
}
140141
if user.Viewer.Blocking != nil {
141-
connections = append(connections, "blocking") // Complete guess
142+
connections.Connection = append(connections.Connection, bridge.Connection{Value: "blocked"})
142143
}
143144
if user.Viewer.BlockedBy {
144-
connections = append(connections, "blocked_by") // Complete guess
145+
connections.Connection = append(connections.Connection, bridge.Connection{Value: "blocked_by"}) // Complete guess
145146
}
146147

147148
relationships = append(relationships, bridge.UserRelationship{

0 commit comments

Comments
 (0)