(c *fiber.Ctx)
| 100 | } |
| 101 | |
| 102 | func UpdateProfile(c *fiber.Ctx) error { |
| 103 | // auth |
| 104 | my_did, pds, _, oauthToken, err := GetAuthFromReq(c) |
| 105 | if err != nil { |
| 106 | return MissingAuth(c, err) |
| 107 | } |
| 108 | |
| 109 | // Lock the mutex for this user |
| 110 | userMutex := getUserMutex(*my_did) |
| 111 | userMutex.Lock() |
| 112 | defer userMutex.Unlock() |
| 113 | |
| 114 | description := c.FormValue("description") |
| 115 | name := c.FormValue("name") |
| 116 | // These don't exist in bluesky. |
| 117 | // location := c.FormValue("location") |
| 118 | // url := c.FormValue("url") |
| 119 | |
| 120 | // some quality of life features |
| 121 | description = strings.ReplaceAll(description, "\\n", "\n") |
| 122 | |
| 123 | oldProfile, err := blueskyapi.GetRecord(*pds, "app.bsky.actor.profile", *my_did, "self") |
| 124 | if err != nil { |
| 125 | return HandleBlueskyError(c, err.Error(), "com.atproto.repo.getRecord", UpdateProfile) |
| 126 | } |
| 127 | |
| 128 | oldProfile.Value.DisplayName = name |
| 129 | oldProfile.Value.Description = description |
| 130 | |
| 131 | if err := blueskyapi.UpdateRecord(*pds, *oauthToken, "app.bsky.actor.profile", *my_did, "self", oldProfile.CID, oldProfile.Value); err != nil { |
| 132 | return HandleBlueskyError(c, err.Error(), "com.atproto.repo.putRecord", UpdateProfile) |
| 133 | } |
| 134 | |
| 135 | user, err := blueskyapi.GetUserInfo(*pds, *oauthToken, *my_did, true) |
| 136 | if err != nil { |
| 137 | fmt.Println("Error:", err) |
| 138 | return HandleBlueskyError(c, err.Error(), "app.bsky.actor.getProfile", UpdateProfile) |
| 139 | } |
| 140 | |
| 141 | user.Description = description |
| 142 | user.Name = name |
| 143 | |
| 144 | return EncodeAndSend(c, user) |
| 145 | } |
| 146 | |
| 147 | func UpdateProfilePicture(c *fiber.Ctx) error { |
| 148 | // auth |
nothing calls this directly
no test coverage detected