Skip to content

feat(39): users()->updateProfilePhoto + deleteProfilePhoto — admin-token multipart upload#40

Open
jordanpartridge wants to merge 1 commit into
mainfrom
feat/39-update-profile-photo
Open

feat(39): users()->updateProfilePhoto + deleteProfilePhoto — admin-token multipart upload#40
jordanpartridge wants to merge 1 commit into
mainfrom
feat/39-update-profile-photo

Conversation

@jordanpartridge
Copy link
Copy Markdown
Contributor

Summary

  • New multipart POST /api/v4/users/{user_id}/image request and the matching DELETE for reset-to-default.
  • Users::updateProfilePhoto(string $userId, string|SplFileInfo|resource $image, ?string $filename = null) and Users::deleteProfilePhoto(string $userId) on the resource.
  • MattermostFake::assertProfilePhotoUpdated() / assertProfilePhotoReset() (filter by user id, exposed on the facade).
  • README "Multi-server > Admin-token operations" walks through pairing a default bot connection with an admin-token connection — bots can't update their own avatar via their own token, so callers route the privileged call through Mattermost::connection('admin').

This unblocks the last direct MattermostService call site in synapse-sentinel/lexi.

Test plan

  • vendor/bin/pest --compact — 347 passed (619 assertions), 16 integration skipped (no docker)
  • vendor/bin/pint --test — clean
  • vendor/bin/phpstan analyse — level 8, no errors
  • Reviewer: spin up docker compose up -d and run vendor/bin/pest --testsuite=Integration to exercise the admin-token round-trip and the bot-token rejection path

Closes #39

…ken multipart upload

Adds a clean swap for the lexi-agent SetProfilePhoto tool: a multipart
POST /users/{id}/image (accepts file path, SplFileInfo, or stream) and
the matching DELETE for resetting to the default avatar.

Bots can't update their own avatar with their own token — pair the
package with a second named connection that holds an admin-grade token,
documented in README "Multi-server > Admin-token operations".

Mattermost::fake() recorder gains assertProfilePhotoUpdated and
assertProfilePhotoReset, both filterable by user id.

Closes #39
Copy link
Copy Markdown

@lexi-chief-of-staff lexi-chief-of-staff Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it.

  • Multipart upload handles paths, SplFileInfo, streams cleanly; throws on invalids.
  • Fakes/asserts track connection name + userId filtering.
  • Tests comprehensive: unit edges, integration real admin/bot flows.
  • README nails the multi-connection pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Mattermost::users()->updateProfilePhoto() — admin-token PATCH

1 participant