Fix friends for seasons 11+
This commit is contained in:
parent
615a53d1ba
commit
495e450a3c
|
@ -793,11 +793,11 @@ func clientGiftCatalogEntryAction(c *fiber.Ctx, person *p.Person, profile *p.Pro
|
||||||
|
|
||||||
socket, ok := socket.JabberSockets.Get(receiverPerson.ID)
|
socket, ok := socket.JabberSockets.Get(receiverPerson.ID)
|
||||||
if ok {
|
if ok {
|
||||||
socket.Write(aid.JSONToBytes(aid.JSON{
|
socket.JabberSendMessageToPerson(aid.JSON{
|
||||||
"payload": aid.JSON{},
|
"payload": aid.JSON{},
|
||||||
"type": "com.epicgames.gift.received",
|
"type": "com.epicgames.gift.received",
|
||||||
"timestamp": time.Now().Format("2006-01-02T15:04:05.999Z"),
|
"timestamp": time.Now().Format("2006-01-02T15:04:05.999Z"),
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,40 @@ func DeleteFriend(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetFriendListSummary(c *fiber.Ctx) error {
|
func GetFriendListSummary(c *fiber.Ctx) error {
|
||||||
return c.Status(200).JSON([]aid.JSON{})
|
person := c.Locals("person").(*p.Person)
|
||||||
|
|
||||||
|
summary := aid.JSON{
|
||||||
|
"friends": []aid.JSON{},
|
||||||
|
"blocklist": []aid.JSON{},
|
||||||
|
"incoming": []aid.JSON{},
|
||||||
|
"outgoing": []aid.JSON{},
|
||||||
|
"suggested": []aid.JSON{},
|
||||||
|
}
|
||||||
|
|
||||||
|
person.Relationships.Range(func(key string, value *p.Relationship) bool {
|
||||||
|
switch value.Direction {
|
||||||
|
case p.RelationshipInboundDirection:
|
||||||
|
res := value.GenerateFortniteSummaryEntry(p.GenerateTypeTowardsPerson)
|
||||||
|
if value.Status == "ACCEPTED" {
|
||||||
|
summary["friends"] = append(summary["friends"].([]aid.JSON), res)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
summary["incoming"] = append(summary["incoming"].([]aid.JSON), res)
|
||||||
|
case p.RelationshipOutboundDirection:
|
||||||
|
res := value.GenerateFortniteSummaryEntry(p.GenerateTypeFromPerson)
|
||||||
|
if value.Status == "ACCEPTED" {
|
||||||
|
summary["friends"] = append(summary["friends"].([]aid.JSON), res)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
summary["outgoing"] = append(summary["outgoing"].([]aid.JSON), res)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
return c.Status(200).JSON(summary)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPersonSearch(c *fiber.Ctx) error {
|
func GetPersonSearch(c *fiber.Ctx) error {
|
||||||
|
|
2
main.go
2
main.go
|
@ -120,7 +120,7 @@ func main() {
|
||||||
friends.Post("/public/friends/:accountId/:wanted", handlers.PostCreateFriend)
|
friends.Post("/public/friends/:accountId/:wanted", handlers.PostCreateFriend)
|
||||||
friends.Delete("/public/friends/:accountId/:wanted", handlers.DeleteFriend)
|
friends.Delete("/public/friends/:accountId/:wanted", handlers.DeleteFriend)
|
||||||
friends.Get("/:version/:accountId/summary", handlers.GetFriendListSummary)
|
friends.Get("/:version/:accountId/summary", handlers.GetFriendListSummary)
|
||||||
friends.Get("/:version/:accountId/friends/:wanted", handlers.PostCreateFriend)
|
friends.Post("/:version/:accountId/friends/:wanted", handlers.PostCreateFriend)
|
||||||
|
|
||||||
game := fortnite.Group("/game/v2")
|
game := fortnite.Group("/game/v2")
|
||||||
game.Get("/enabled_features", handlers.GetGameEnabledFeatures)
|
game.Get("/enabled_features", handlers.GetGameEnabledFeatures)
|
||||||
|
|
|
@ -50,6 +50,25 @@ func (r *Relationship) GenerateFortniteFriendEntry(t RelationshipGenerateType) a
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Relationship) GenerateFortniteSummaryEntry(t RelationshipGenerateType) aid.JSON {
|
||||||
|
result := aid.JSON{
|
||||||
|
"created": time.Now().Add(-time.Hour * 24 * 3).Format(time.RFC3339),
|
||||||
|
"favorite": false,
|
||||||
|
"groups": []string{},
|
||||||
|
"mutual": 0,
|
||||||
|
"note": "",
|
||||||
|
}
|
||||||
|
|
||||||
|
switch t {
|
||||||
|
case GenerateTypeFromPerson:
|
||||||
|
result["accountId"] = r.Towards.ID
|
||||||
|
case GenerateTypeTowardsPerson:
|
||||||
|
result["accountId"] = r.From.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Relationship) Save() (*Relationship, error) {
|
func (r *Relationship) Save() (*Relationship, error) {
|
||||||
storage.Repo.Storage.SaveRelationship(r.ToDatabase())
|
storage.Repo.Storage.SaveRelationship(r.ToDatabase())
|
||||||
r.From.Relationships.Set(r.Towards.ID, r)
|
r.From.Relationships.Set(r.Towards.ID, r)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user