Add presence set-preferred and clear-preferred - #92
Open
aberoham wants to merge 3 commits into
Open
Conversation
Microsoft Graph keeps a user-preferred presence above the presence sessions and ranks it first for as long as at least one session exists. The Teams client's "Appear offline" lives there, as `Offline`/`OffWork`, and nothing in the CLI could reach it: `presence set` answered success and the account stayed offline, because the override sat on top of the session it had just opened.
`set-preferred` calls `setUserPreferredPresence` and `clear-preferred` calls `clearUserPreferredPresence`, both under `/me/presence` like the other writes. Graph accepts six availabilities here, each with exactly one activity, so the command takes `--availability` alone, derives the activity, and reports both back rather than letting a caller send a pair Graph rejects. `--expiration` is checked as a positive ISO 8601 duration and left unbounded: Graph documents defaults of one day for `Busy` and `DoNotDisturb` and seven days otherwise, not a range, and the PT5M to PT4H limits in `parse_expiration` belong to sessions. The clear body is `{}` as documented, which a braced struct serializes to where a unit struct would send `null`; the wiremock test would catch the difference.
Verified against a live tenant: an account carrying `Offline`/`OffWork` with an open Available session read `Available`/`Available` after `clear-preferred`; `set-preferred --availability Away` read `Away`/`Away` through both the single-user and batch read paths; and a second clear with nothing left to clear returned 200 rather than 404, so there is no miss to translate.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DD81KRhjKrJi3Gywivwv1
Contributor
Author
|
Adversarial review completed against base 979791f through the updated head 90466fe. Findings fixed:
Validation completed:
I also checked the current Microsoft Graph v1.0 documentation for The fork-origin GitHub Actions run currently shows No further code, dependency, or documentation findings remain. Merge-ready once hosted CI is approved and passes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
presence set-preferredandpresence clear-preferredmanage the user-preferred presence, which Microsoft Graph ranks above every presence session while one exists.Offline/OffWork. With it set,presence setreturns success and the account stays offline, and no command could clear it.set-preferred --availability A [--expiration D]callssetUserPreferredPresence. Graph acceptsAvailable,Busy,DoNotDisturb,BeRightBack,AwayandOffline, each with one fixed activity, so the activity is derived from the availability and reported back.--expirationis checked as a positive ISO 8601 duration and not bounded. Graph documents defaults of one day forBusyandDoNotDisturband seven days otherwise, rather than a range, so thePT5MtoPT4Hcheck onsetdoes not apply here.clear-preferredcallsclearUserPreferredPresencewith the documented{}body. A second clear with nothing to clear returns 200, so there is no 404 to translate.CLAUDE.mdandAGENTS.mdare updated.Sample output:
{"status": "preferred_presence_set", "availability": "Away", "activity": "Away", "expiration_duration": "PT1H"}{"status": "preferred_presence_cleared"}Verified against a live tenant on 2026-09-03: an account carrying
Offline/OffWorkwith an open Available session readAvailable/Availableafterclear-preferred;set-preferred --availability AwayreadAway/Awaythrough bothpresence getandpresence get-batch; a secondclear-preferredreturned 200.