Proper affiliate rewards

This commit is contained in:
Eccentric 2024-02-14 23:07:05 +00:00
parent bb3dbe5718
commit a179961138
3 changed files with 38 additions and 27 deletions

View File

@ -17,7 +17,7 @@ import (
var ( var (
clientActions = map[string]func(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error { clientActions = map[string]func(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error {
"QueryProfile": clientQueryProfileAction, "QueryProfile": clientQueryProfileAction,
"ClientQuestLogin": clientQueryProfileAction, "ClientQuestLogin": clientClientQuestLoginAction,
"MarkItemSeen": clientMarkItemSeenAction, "MarkItemSeen": clientMarkItemSeenAction,
"SetItemFavoriteStatusBatch": clientSetItemFavoriteStatusBatchAction, "SetItemFavoriteStatusBatch": clientSetItemFavoriteStatusBatchAction,
"EquipBattleRoyaleCustomization": clientEquipBattleRoyaleCustomizationAction, "EquipBattleRoyaleCustomization": clientEquipBattleRoyaleCustomizationAction,
@ -89,28 +89,28 @@ func PostClientProfileAction(c *fiber.Ctx) error {
delete(profileSnapshots, profile.Type) delete(profileSnapshots, profile.Type)
multiUpdate := []aid.JSON{} multiUpdate := []aid.JSON{}
for key := range profileSnapshots { for key := range profileSnapshots {
profile := person.GetProfileFromType(key) profile := person.GetProfileFromType(key)
if profile == nil { if profile == nil {
continue continue
}
profile.Revision++
if len(profile.Changes) == 0 {
continue
}
multiUpdate = append(multiUpdate, aid.JSON{
"profileId": profile.Type,
"profileRevision": profile.Revision,
"profileCommandRevision": profile.Revision,
"profileChangesBaseRevision": profile.Revision - 1,
"profileChanges": profile.Changes,
})
profile.ClearProfileChanges()
go profile.Save()
} }
profile.Revision++
if len(profile.Changes) == 0 {
continue
}
multiUpdate = append(multiUpdate, aid.JSON{
"profileId": profile.Type,
"profileRevision": profile.Revision,
"profileCommandRevision": profile.Revision,
"profileChangesBaseRevision": profile.Revision - 1,
"profileChanges": profile.Changes,
})
profile.ClearProfileChanges()
go profile.Save()
}
return c.Status(200).JSON(aid.JSON{ return c.Status(200).JSON(aid.JSON{
"profileId": c.Query("profileId"), "profileId": c.Query("profileId"),
@ -130,6 +130,10 @@ func clientQueryProfileAction(c *fiber.Ctx, person *p.Person, profile *p.Profile
return nil return nil
} }
func clientClientQuestLoginAction(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error {
return nil
}
func clientMarkItemSeenAction(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error { func clientMarkItemSeenAction(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error {
var body struct { var body struct {
ItemIds []string `json:"itemIds"` ItemIds []string `json:"itemIds"`
@ -664,6 +668,17 @@ func clientPurchaseCatalogEntryAction(c *fiber.Ctx, person *p.Person, profile *p
"primary": true, "primary": true,
}) })
affiliate := person.CommonCoreProfile.Attributes.GetAttributeByKey("mtx_affiliate")
if affiliate == nil {
return c.Status(400).JSON(aid.ErrorBadRequest("Invalid affiliate attribute"))
}
creator := p.Find(p.AttributeConvert[string](affiliate))
if creator != nil {
creator.CommonCoreProfile.Items.GetItemByTemplateID("Currency:MtxPurchased").Quantity += body.ExpectedTotalPrice
creator.Profile0Profile.Items.GetItemByTemplateID("Currency:MtxPurchased").Quantity += body.ExpectedTotalPrice
}
return nil return nil
} }

View File

@ -152,12 +152,10 @@ func main() {
party := r.Group("/party/api/v1/Fortnite") party := r.Group("/party/api/v1/Fortnite")
party.Use(handlers.MiddlewareFortnite) party.Use(handlers.MiddlewareFortnite)
party.Get("/user/:accountId", handlers.GetPartiesForUser) party.Get("/user/:accountId", handlers.GetPartiesForUser)
party.Get("/user/:accountId/settings/privacy", handlers.GetPartyUserPrivacy) party.Get("/user/:accountId/settings/privacy", handlers.GetPartyUserPrivacy)
party.Get("/user/:accountId/notifications/undelivered/count", handlers.GetPartyNotifications) party.Get("/user/:accountId/notifications/undelivered/count", handlers.GetPartyNotifications)
party.Get("/user/:accountId/pings/:friendId/parties", handlers.GetPartyPingsFromFriend) party.Get("/user/:accountId/pings/:friendId/parties", handlers.GetPartyPingsFromFriend)
party.Get("/parties/:partyId", handlers.GetPartyForMember) party.Get("/parties/:partyId", handlers.GetPartyForMember)
party.Post("/parties", handlers.PostPartyCreate) party.Post("/parties", handlers.PostPartyCreate)
party.Post("/parties/:partyId/invites/:accountId", handlers.PostPartyInvite) party.Post("/parties/:partyId/invites/:accountId", handlers.PostPartyInvite)
@ -166,9 +164,7 @@ func main() {
party.Patch("/parties/:partyId", handlers.PatchPartyUpdateState) party.Patch("/parties/:partyId", handlers.PatchPartyUpdateState)
party.Patch("/parties/:partyId/members/:accountId/meta", handlers.PatchPartyUpdateMemberState) party.Patch("/parties/:partyId/members/:accountId/meta", handlers.PatchPartyUpdateMemberState)
party.Delete("/parties/:partyId/members/:accountId", handlers.DeletePartyMember) party.Delete("/parties/:partyId/members/:accountId", handlers.DeletePartyMember)
// post /parties/:partyId/members/:accountId/conferences/connection (join a voip channel) // post /parties/:partyId/members/:accountId/conferences/connection (join a voip channel)
// get /user/:accountId/pings/:pinger/friendId/parties (get pings from a friend) // get /user/:accountId/pings/:pinger/friendId/parties (get pings from a friend)
// post /user/:accountId/pings/:pinger/join (join a party from a ping) // post /user/:accountId/pings/:pinger/join (join a party from a ping)
// post /user/:friendId/pings/:accountId (send a ping) // post /user/:friendId/pings/:accountId (send a ping)

View File

@ -4,7 +4,7 @@ import "github.com/ectrc/snow/aid"
type FullProfileUpdate struct { type FullProfileUpdate struct {
ChangeType string `json:"changeType"` ChangeType string `json:"changeType"`
Profile aid.JSON `json:"profile"` Profile interface{} `json:"profile"`
} }
type StatModified struct { type StatModified struct {