Improve query profile

This commit is contained in:
Eccentric 2024-01-31 16:20:43 +00:00
parent 68000b5d57
commit 4ce93be2c5

View File

@ -44,7 +44,6 @@ func PostClientProfileAction(c *fiber.Ctx) error {
"common_core": nil,
"common_public": nil,
}
for key := range profileSnapshots {
profileSnapshots[key] = person.GetProfileFromType(key).Snapshot()
}
@ -71,7 +70,8 @@ func PostClientProfileAction(c *fiber.Ctx) error {
profile.Diff(profileSnapshot)
}
revision, _ := strconv.Atoi(c.Query("rvn"))
known, _ := strconv.Atoi(c.Query("rvn"))
revision := known
if revision == -1 {
revision = profile.Revision
}
@ -81,6 +81,8 @@ func PostClientProfileAction(c *fiber.Ctx) error {
delete(profileSnapshots, profile.Type)
multiUpdate := []aid.JSON{}
if known != -1 {
for key := range profileSnapshots {
profile := person.GetProfileFromType(key)
if profile == nil {
@ -103,6 +105,7 @@ func PostClientProfileAction(c *fiber.Ctx) error {
profile.ClearProfileChanges()
go profile.Save()
}
}
return c.Status(200).JSON(aid.JSON{
"profileId": c.Query("profileId"),
@ -118,7 +121,11 @@ func PostClientProfileAction(c *fiber.Ctx) error {
}
func clientQueryProfileAction(c *fiber.Ctx, person *p.Person, profile *p.Profile, notifications *[]aid.JSON) error {
known, _ := strconv.Atoi(c.Query("rvn"))
if known == -1 {
profile.CreateFullProfileUpdateChange()
}
return nil
}