newOS for Developers
Back to Mood Management
Mood Access Control
intermediateGrant or request access to private moods
POST /mood/access/grantPOST /mood/access/requestOverview
Private moods require explicit access grants. The owner can grant access to specific users, or users can request access which the owner can approve. Access levels includeread andwrite.
Grant Access
import { grantWriteAccess } from "newgraph-signals/actions/folder";
// Grant write access to a single user
await grantWriteAccess({
user: { id: "user-uuid", username: "grantee" },
folder: { id: "folder-uuid" },
accessLevel: "write" // "read" | "write" (default: "write")
});
// Grant access to multiple users at once
import { grantWriteAccessMulti } from "newgraph-signals/actions/folder";
const progress = grantWriteAccessMulti();
progress.exec({
users: [
{ id: "user1-uuid", username: "user1" },
{ id: "user2-uuid", username: "user2" }
],
folders: [folder],
ignoreOneOnOne: false // If true, skips 1:1 folder conversion
});Request Access
import { requestAccess } from "newgraph-signals/actions/folder";
// Request access to a private folder
await requestAccess({
folder: { id: "folder-uuid" }
});
// This creates an edge with level: "request"
// The folder owner can then approve via grantWriteAccessRead Grantees
import { readFolderGrantees } from "newgraph-signals/actions/folder";
// Get list of users with access to a folder
const progress = readFolderGrantees({ id: "folder-uuid" });
// Progressive handler returns paginated results
progress.value; // Array of UserReadPublicResponseWithAccess
progress.done; // boolean
progress.page; // current page numberAccess Levels
| Level | Read | Write | Description |
|---|---|---|---|
| read | ✅ | ❌ | View content only |
| write | ✅ | ✅ | View and add content |
| request | ❌ | ❌ | Pending approval |
| denied | ❌ | ❌ | Explicitly blocked |
Cache Edge Pattern
// Edge created on access grant
{
from: "user-id",
fromLabel: "user",
to: "folder-id",
toLabel: "folder",
label: "access",
props: { level: "write", updated: "2024-01-15T10:30:00Z" }
}
// Query pattern for folder grantees
cache.__EDGES
.where("__outE")
.startsWith(`folder+${folderId}+access+user`)Edge Cases
OneOnOne Folders: When granting access to a 1:1 folder with
ignoreOneOnOne: true, the folder type is preserved instead of converting to a group folder.Future Folders: Access can be granted to "future" folders that haven't been committed yet. Grantees are stored in
futureGrantees.Cache Update: Access edges are cached immediately for optimistic UI, then synced with the server.