mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-10 13:10:14 +00:00
Client, mapping, and capability layer only — intentionally NOT wired into any
lifecycle/trigger path yet (no coordinator, no workers).
- types/api/drafts.d.ts: add DraftApi (server response) and DraftUpsertRequest
(POST body) DTOs alongside DraftProps.
- types/api/config.d.ts: add AllowSyncedDrafts to ClientConfig.
- client/rest/base.ts: add draft route helpers (drafts POST, user/team GET,
channel/thread DELETE).
- client/rest/drafts.ts (+test): ClientDrafts mixin — getDrafts, upsertDraft,
deleteDraft (channel vs thread by rootId), Connection-Id header on POST/DELETE.
Mixed into client/rest/index.ts (also drops a pre-existing duplicate
ClientScheduledPost entry in the .with() list).
- constants/preferences.ts: add ADVANCED_SYNC_DRAFTS ('sync_drafts').
- utils/draft/sync.ts (+test): pure bidirectional normalization. server->mobile
maps update_at->server_update_at (never local update_at), priority, props
passthrough, exact file_ids, files from metadata.files; mobile->server sends
only channel_id/root_id/message/type/props/file_ids/priority and returns null
for an empty message so it never POSTs. Fail-closed burn-on-read reconstruction
(durations come from server config, not props; missing/invalid -> no enabled
borConfig).
- queries/servers/drafts.ts: getIsDraftSyncEnabled / observeIsDraftSyncEnabled —
enabled when AllowSyncedDrafts==='true' AND sync_drafts pref not 'false'
(absent = enabled). No server-version gate.
Checks: npm run tsc clean; eslint --quiet clean; 69 focused Jest tests pass
across the new client/sync suites and the scheduled_post/post-handler/drafts
regression neighbors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98 lines
3.5 KiB
TypeScript
98 lines
3.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import ClientAgents, {type ClientAgentsMix} from '@agents/client/rest';
|
|
import ClientCalls, {type ClientCallsMix} from '@calls/client/rest';
|
|
import ClientPlugins, {type ClientPluginsMix} from '@client/rest/plugins';
|
|
import ClientPlaybooks, {type ClientPlaybooksMix} from '@playbooks/client/rest';
|
|
import mix from '@utils/mix';
|
|
|
|
import ClientApps, {type ClientAppsMix} from './apps';
|
|
import ClientBase from './base';
|
|
import ClientCategories, {type ClientCategoriesMix} from './categories';
|
|
import ClientChannelBookmarks, {type ClientChannelBookmarksMix} from './channel_bookmark';
|
|
import ClientChannels, {type ClientChannelsMix} from './channels';
|
|
import {DEFAULT_LIMIT_AFTER, DEFAULT_LIMIT_BEFORE, HEADER_X_VERSION_ID} from './constants';
|
|
import ClientCustomAttributes, {type ClientCustomAttributesMix} from './custom_profile_attributes';
|
|
import ClientDrafts, {type ClientDraftsMix} from './drafts';
|
|
import ClientEmojis, {type ClientEmojisMix} from './emojis';
|
|
import ClientFiles, {type ClientFilesMix} from './files';
|
|
import ClientGeneral, {type ClientGeneralMix} from './general';
|
|
import ClientGroups, {type ClientGroupsMix} from './groups';
|
|
import ClientIntegrations, {type ClientIntegrationsMix} from './integrations';
|
|
import ClientNPS, {type ClientNPSMix} from './nps';
|
|
import ClientPosts, {type ClientPostsMix} from './posts';
|
|
import ClientPreferences, {type ClientPreferencesMix} from './preferences';
|
|
import ClientProperties, {type ClientPropertiesMix} from './properties';
|
|
import ClientScheduledPost, {type ClientScheduledPostMix} from './scheduled_post';
|
|
import ClientTeams, {type ClientTeamsMix} from './teams';
|
|
import ClientThreads, {type ClientThreadsMix} from './threads';
|
|
import ClientTos, {type ClientTosMix} from './tos';
|
|
import ClientUsers, {type ClientUsersMix} from './users';
|
|
|
|
import type {APIClientInterface} from '@mattermost/react-native-network-client';
|
|
|
|
interface Client extends ClientBase,
|
|
ClientAgentsMix,
|
|
ClientAppsMix,
|
|
ClientCategoriesMix,
|
|
ClientChannelsMix,
|
|
ClientChannelBookmarksMix,
|
|
ClientEmojisMix,
|
|
ClientFilesMix,
|
|
ClientGeneralMix,
|
|
ClientGroupsMix,
|
|
ClientIntegrationsMix,
|
|
ClientPostsMix,
|
|
ClientPreferencesMix,
|
|
ClientPropertiesMix,
|
|
ClientScheduledPostMix,
|
|
ClientTeamsMix,
|
|
ClientThreadsMix,
|
|
ClientTosMix,
|
|
ClientUsersMix,
|
|
ClientCallsMix,
|
|
ClientPluginsMix,
|
|
ClientNPSMix,
|
|
ClientCustomAttributesMix,
|
|
ClientDraftsMix,
|
|
ClientPlaybooksMix
|
|
{
|
|
setClientCredentials: (token: string, preauthSecret?: string) => void;
|
|
setCSRFToken: (csrfToken: string) => void;
|
|
}
|
|
|
|
class Client extends mix(ClientBase).with(
|
|
ClientAgents,
|
|
ClientApps,
|
|
ClientCategories,
|
|
ClientChannels,
|
|
ClientChannelBookmarks,
|
|
ClientEmojis,
|
|
ClientFiles,
|
|
ClientGeneral,
|
|
ClientGroups,
|
|
ClientIntegrations,
|
|
ClientPosts,
|
|
ClientPreferences,
|
|
ClientProperties,
|
|
ClientScheduledPost,
|
|
ClientTeams,
|
|
ClientThreads,
|
|
ClientTos,
|
|
ClientUsers,
|
|
ClientCalls,
|
|
ClientPlugins,
|
|
ClientNPS,
|
|
ClientCustomAttributes,
|
|
ClientDrafts,
|
|
ClientPlaybooks,
|
|
) {
|
|
// eslint-disable-next-line no-useless-constructor
|
|
constructor(apiClient: APIClientInterface, serverUrl: string, bearerToken?: string, csrfToken?: string, preauthSecret?: string) {
|
|
super(apiClient, serverUrl, bearerToken, csrfToken, preauthSecret);
|
|
}
|
|
}
|
|
|
|
export {Client, DEFAULT_LIMIT_AFTER, DEFAULT_LIMIT_BEFORE, HEADER_X_VERSION_ID};
|