Share chat attachments with the chat's members after upload - #93
Conversation
42f727e to
65df9f6
Compare
`message send --chat … --attach FILE` uploads into the sender's OneDrive
("Microsoft Teams Chat Files") and links the driveItem from the message, but
nobody else could open it: the Teams client grants every chat member read
permission when it attaches a file, and the CLI did not. Recipients saw
"you don't have permission" (observed live, 2026-09-03).
After each chat upload the CLI now lists the chat's members once and grants
them read access through the driveItem's `invite` action, with
requireSignIn=true and no notification email. Members are addressed by Entra
object ID where the membership carries one (covers accounts without a mail
attribute), else by email; the sender and members with neither are skipped,
and duplicates collapse. The grant is best-effort: if it fails the upload and
message still go through and a warning on stderr says to share the file from
OneDrive by hand. Channel attachments are unchanged — they live in the team's
SharePoint library, which channel members already read.
`AttachDestination::Chat` now carries the chat id so the media layer can look
the members up. New: `endpoints::me_drive_item_invite`, `DriveInviteRequest`
/ `DriveRecipient` / `DrivePermission` models, `files::grant_read_access`.
Unit tests cover recipient selection and the invite request's JSON shape;
docs and CHANGELOG updated.
Verified live in a four-member meeting chat: the debug log reports the file
shared with 3 members and Graph lists a read permission for each.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The best-effort follow-up shortened the entry to the mechanism and lost the symptom it fixes. Keep the symptom, the invite mechanics, the tenant rule and the best-effort behaviour in one entry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WG7vFLjFZHqAUMRS1zkWRE
65df9f6 to
261c14b
Compare
|
Reviewed and verified locally:
Two things the original diff did not do that its description promised, now fixed on the branch via @aberoham's follow-up commit:
Also restored the changelog entry's account of the symptom (the follow-up had shortened it), and rebased onto |
|
@philipwilsonTHG a few questions so we can close the verification gap on our side (our sandbox token has no
Thanks for the fix, it is in |
|
Thanks for the review and the two fixes — both are real gaps in what I sent. Re-ran today against merged
[
{"id": "<redacted>", "roles": ["read"], "grantedToV2": {"user": {"displayName": "<member 1>", "id": "<redacted>", "email": "<redacted>"}}},
{"id": "<redacted>", "roles": ["read"], "grantedToV2": {"user": {"displayName": "<member 2>", "id": "<redacted>", "email": "<redacted>"}}},
{"id": "<redacted>", "roles": ["read"], "grantedToV2": {"user": {"displayName": "<member 3>", "id": "<redacted>", "email": "<redacted>"}}},
{"id": "<redacted>", "roles": ["owner"], "grantedToV2": {"user": {"displayName": "<sender>", "id": "<redacted>", "email": "<redacted>"}}}
]No
|
Problem
teams message send --chat … --attach FILEuploads the file into the sender's OneDrive (Microsoft Teams Chat Files) and links the driveItem from the message, but nobody else in the chat can open it: the Teams client grants every chat member read permission when it attaches a file, and the CLI did not. Recipients saw "you don't have permission".Fix
After each chat upload the CLI now lists the chat's members once and grants them read access through the driveItem's
inviteaction (roles: ["read"],requireSignIn: true,sendInvitation: false— no notification email). Members are addressed by Entra object ID where the membership carries one (covers accounts without a mail attribute), else by email; the sender and members with neither are skipped, and duplicates collapse.The grant is best-effort: if it fails (for example a token that cannot list chat members) the upload and message still go through and a warning on stderr says to share the file from OneDrive by hand. Channel attachments are unchanged — they live in the team's SharePoint library, which channel members already read.
Changes
AttachDestination::Chatcarries the chat id so the media layer can look the members up.endpoints::me_drive_item_invite,DriveInviteRequest/DriveRecipient/DrivePermissionmodels,files::grant_read_access.Verified
Live in a four-member chat: the debug log reports the file shared with 3 members and Graph lists a read permission for each of them, with the sender as owner.
🤖 Generated with Claude Code