Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp
613 B
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-or-later

import type {ReadState} from '@app/api/models/ReadState';
import type {ReadStateResponse} from '@fluxer/schema/src/domains/gateway/GatewaySchemas';

export function mapReadStateResponse(readState: ReadState): ReadStateResponse {
	return {
		id: readState.channelId.toString(),
		mention_count: readState.mentionCount,
		last_message_id: readState.lastMessageId?.toString() ?? null,
		last_pin_timestamp: readState.lastPinTimestamp?.toISOString() ?? null,
		version: readState.version.toString(),
		...(readState.isMarked ? {flags: readState.flags ?? 0} : {}),
	};
}