newOS for Developers
Back to Mood Management
OneOnOne (DM)
intermediateCreate or retrieve a direct message folder between two users
GET /mood/oneonone/{id}Overview
OneOnOne folders are special private moods designed for direct messaging between exactly two users. The folder ID is deterministic: a sorted combination of both user IDs joined with an underscore (userId1_userId2).
If the folder doesn't exist, it's created automatically. The folder hasdefaultView: "chat" for optimal messaging display.
Request
import { getOneOnOneFolder } from "newgraph-signals/actions/folder";
// Get or create a DM folder with another user
const progress = getOneOnOneFolder({
id: "other-user-uuid",
username: "otheruser" // Optional, for display
});
// Progressive handler provides caching + API sync
progress.value; // EnrichedFolder | undefined
progress.done; // boolean
progress.loading; // booleanDeterministic ID
// The oneOnOne folder ID is deterministically generated
const currUser = currentUser.id; // e.g., "alice-uuid"
const targetUser = otherUser.id; // e.g., "bob-uuid"
// IDs are sorted alphabetically and joined
const oneOnOneId = [currUser, targetUser].sort().join("_");
// Result: "alice-uuid_bob-uuid"
// This ensures both users get the same folder ID
// regardless of who initiates the conversationResponse
// EnrichedFolder for OneOnOne
{
"id": "alice-uuid_bob-uuid",
"title": "alice - bob",
"defaultView": "chat",
"isPrivate": true,
"oneOnOne": ["alice-uuid", "bob-uuid"],
"author": {
"id": "alice-uuid",
"username": "alice"
},
"created": "2024-01-15T10:30:00Z"
}OneOnOne Folder Properties
| Property | Value | Description |
|---|---|---|
| id | user1_user2 | Sorted user IDs joined with underscore |
| title | "user1 - user2" | Auto-generated from usernames |
| defaultView | "chat" | Optimized for messaging UI |
| isPrivate | true | Always private |
| oneOnOne | [userId1, userId2] | Array of participant IDs |
Edge Cases
Cache Check First: The function first checks the cache for an existing 1:1 folder before making an API call.
Adding Third User: If you try to add a third user to a 1:1 folder, use
ignoreOneOnOne: true in grantWriteAccessMulti to convert it to a group folder.Deleted Check: The cache query filters out folders marked as
deleted.