Add deleting friends
This commit is contained in:
parent
0951a63bfe
commit
6fc1694930
|
@ -56,6 +56,36 @@ func PostCreateFriend(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteFriend(c *fiber.Ctx) error {
|
func DeleteFriend(c *fiber.Ctx) error {
|
||||||
|
person := c.Locals("person").(*p.Person)
|
||||||
|
|
||||||
|
relationship, found := person.Relationships.Get(c.Params("wanted"))
|
||||||
|
if !found {
|
||||||
|
return c.Status(404).JSON(aid.ErrorNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
from, found := socket.JabberSockets.Get(relationship.From.ID)
|
||||||
|
if found {
|
||||||
|
from.JabberSendMessageToPerson(aid.JSON{
|
||||||
|
"type": "com.epicgames.friends.core.apiobjects.FriendRemoval",
|
||||||
|
"timestamp": time.Now().Format(time.RFC3339),
|
||||||
|
"payload": relationship.GenerateFortniteFriendRemovalEntry(p.GenerateTypeFromPerson),
|
||||||
|
})
|
||||||
|
from.JabberNotifyFriends()
|
||||||
|
}
|
||||||
|
|
||||||
|
towards, found := socket.JabberSockets.Get(relationship.Towards.ID)
|
||||||
|
if found {
|
||||||
|
towards.JabberSendMessageToPerson(aid.JSON{
|
||||||
|
"type": "com.epicgames.friends.core.apiobjects.FriendRemoval",
|
||||||
|
"timestamp": time.Now().Format(time.RFC3339),
|
||||||
|
"payload": relationship.GenerateFortniteFriendRemovalEntry(p.GenerateTypeTowardsPerson),
|
||||||
|
})
|
||||||
|
towards.JabberNotifyFriends()
|
||||||
|
}
|
||||||
|
|
||||||
|
relationship.Delete()
|
||||||
|
person.Relationships.Delete(c.Params("friend"))
|
||||||
|
|
||||||
return c.SendStatus(204)
|
return c.SendStatus(204)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
main.go
1
main.go
|
@ -135,6 +135,7 @@ func main() {
|
||||||
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.Post("/:version/:accountId/friends/:wanted", handlers.PostCreateFriend)
|
friends.Post("/:version/:accountId/friends/:wanted", handlers.PostCreateFriend)
|
||||||
|
friends.Delete("/:version/:accountId/friends/:wanted", handlers.DeleteFriend)
|
||||||
|
|
||||||
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,22 @@ func (r *Relationship) GenerateFortniteFriendEntry(t RelationshipGenerateType) a
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Relationship) GenerateFortniteFriendRemovalEntry(t RelationshipGenerateType) aid.JSON {
|
||||||
|
result := aid.JSON{
|
||||||
|
"reason": "DELETED",
|
||||||
|
}
|
||||||
|
|
||||||
|
switch t {
|
||||||
|
case GenerateTypeFromPerson:
|
||||||
|
result["accountId"] = r.Towards.ID
|
||||||
|
case GenerateTypeTowardsPerson:
|
||||||
|
result["accountId"] = r.From.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *Relationship) GenerateFortniteSummaryEntry(t RelationshipGenerateType) aid.JSON {
|
func (r *Relationship) GenerateFortniteSummaryEntry(t RelationshipGenerateType) aid.JSON {
|
||||||
result := aid.JSON{
|
result := aid.JSON{
|
||||||
"created": time.Now().Add(-time.Hour * 24 * 3).Format(time.RFC3339),
|
"created": time.Now().Add(-time.Hour * 24 * 3).Format(time.RFC3339),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user