Proper affiliate rewards
This commit is contained in:
parent
bb3dbe5718
commit
a179961138
|
@ -17,7 +17,7 @@ import (
|
|||
var (
|
||||
clientActions = map[string]func(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error {
|
||||
"QueryProfile": clientQueryProfileAction,
|
||||
"ClientQuestLogin": clientQueryProfileAction,
|
||||
"ClientQuestLogin": clientClientQuestLoginAction,
|
||||
"MarkItemSeen": clientMarkItemSeenAction,
|
||||
"SetItemFavoriteStatusBatch": clientSetItemFavoriteStatusBatchAction,
|
||||
"EquipBattleRoyaleCustomization": clientEquipBattleRoyaleCustomizationAction,
|
||||
|
@ -89,28 +89,28 @@ func PostClientProfileAction(c *fiber.Ctx) error {
|
|||
delete(profileSnapshots, profile.Type)
|
||||
|
||||
multiUpdate := []aid.JSON{}
|
||||
for key := range profileSnapshots {
|
||||
profile := person.GetProfileFromType(key)
|
||||
if profile == nil {
|
||||
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()
|
||||
for key := range profileSnapshots {
|
||||
profile := person.GetProfileFromType(key)
|
||||
if profile == nil {
|
||||
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()
|
||||
}
|
||||
|
||||
return c.Status(200).JSON(aid.JSON{
|
||||
"profileId": c.Query("profileId"),
|
||||
|
@ -130,6 +130,10 @@ func clientQueryProfileAction(c *fiber.Ctx, person *p.Person, profile *p.Profile
|
|||
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 {
|
||||
var body struct {
|
||||
ItemIds []string `json:"itemIds"`
|
||||
|
@ -664,6 +668,17 @@ func clientPurchaseCatalogEntryAction(c *fiber.Ctx, person *p.Person, profile *p
|
|||
"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
|
||||
}
|
||||
|
||||
|
|
4
main.go
4
main.go
|
@ -152,12 +152,10 @@ func main() {
|
|||
|
||||
party := r.Group("/party/api/v1/Fortnite")
|
||||
party.Use(handlers.MiddlewareFortnite)
|
||||
|
||||
party.Get("/user/:accountId", handlers.GetPartiesForUser)
|
||||
party.Get("/user/:accountId/settings/privacy", handlers.GetPartyUserPrivacy)
|
||||
party.Get("/user/:accountId/notifications/undelivered/count", handlers.GetPartyNotifications)
|
||||
party.Get("/user/:accountId/pings/:friendId/parties", handlers.GetPartyPingsFromFriend)
|
||||
|
||||
party.Get("/parties/:partyId", handlers.GetPartyForMember)
|
||||
party.Post("/parties", handlers.PostPartyCreate)
|
||||
party.Post("/parties/:partyId/invites/:accountId", handlers.PostPartyInvite)
|
||||
|
@ -166,9 +164,7 @@ func main() {
|
|||
party.Patch("/parties/:partyId", handlers.PatchPartyUpdateState)
|
||||
party.Patch("/parties/:partyId/members/:accountId/meta", handlers.PatchPartyUpdateMemberState)
|
||||
party.Delete("/parties/:partyId/members/:accountId", handlers.DeletePartyMember)
|
||||
|
||||
// post /parties/:partyId/members/:accountId/conferences/connection (join a voip channel)
|
||||
|
||||
// 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/:friendId/pings/:accountId (send a ping)
|
||||
|
|
|
@ -4,7 +4,7 @@ import "github.com/ectrc/snow/aid"
|
|||
|
||||
type FullProfileUpdate struct {
|
||||
ChangeType string `json:"changeType"`
|
||||
Profile aid.JSON `json:"profile"`
|
||||
Profile interface{} `json:"profile"`
|
||||
}
|
||||
|
||||
type StatModified struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user