chatmap

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package chatmap converts notification-service chat proto messages into gateway API resources. It is shared by the messaging endpoint packages (conversations, messages, participants, scheduled messages, attachments, blocks) and the resource loaders so the proto→resource mapping lives in one place.

The base mappers (ConversationFromProto, MessageFromProto) populate only inline fields and leave every expandable sub-object (assignee, group, topic, participants, last_message, sender, author, attachments, resource, reply_to, conversation) nil. The Stash* helpers build those sub-objects and stash them in the request-scoped LoadMeta so the include resolver can attach them only when the caller requests them via ?include=. Name hydration is layered on top in the endpoint services / loaders (chatmap must not import resourceloaders — that would be an import cycle).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachmentFromProto

func AttachmentFromProto(ctx context.Context, a *pb.AttachmentInfo) apiresource.MessageAttachment

AttachmentFromProto maps a message attachment to its API resource.

func AuthorActorFromProto

func AuthorActorFromProto(m *pb.MessageInfo) *apiresource.Actor

AuthorActorFromProto builds the underlying author actor — an account user or an agent. It is nil for system messages and when an anonymizing sender identity hides the real author (the server strips the backing ids in that case).

func ConversationFromProto

func ConversationFromProto(c *pb.ConversationInfo) apiresource.Conversation

ConversationFromProto maps a conversation to its base API resource. Expandable sub-objects (assignee, group, topic, participants, last_message) are left nil — call StashConversationMeta to make them resolvable via ?include=.

func ConversationLinkFromProto

func ConversationLinkFromProto(l *pb.ConversationLinkInfo) apiresource.ConversationLink

ConversationLinkFromProto maps a conversation link to its base API resource (the linked record as a bare id+type Entity; the display name is hydrated downstream where needed). The expandable `conversation` sub-object is left nil — call StashConversationLinkMeta to make it resolvable via ?include=conversation.

func ConversationStatusFromProto

func ConversationStatusFromProto(status string, hidden bool) constants.ConversationStatus

ConversationStatusFromProto maps the proto status + per-caller hidden flag to the resource enum. Hidden takes precedence over the account-level status; an empty status defaults to active.

func MessageFromProto

func MessageFromProto(m *pb.MessageInfo) apiresource.Message

MessageFromProto maps a chat message to its base API resource. Expandable sub-objects (conversation, sender, author, resource, reply_to, attachments) are left nil — call StashMessageMeta to make them resolvable via ?include=.

func OkMessage

func OkMessage(msg string) *apiresource.MessageResource

OkMessage builds a human-readable confirmation for actions that produce no resource.

func ParticipantFromProto

func ParticipantFromProto(p *pb.ParticipantInfo) apiresource.ConversationParticipant

ParticipantFromProto maps a conversation participant to its API resource. The actor carries id + type only; display names are hydrated downstream.

func SenderActorFromProto

func SenderActorFromProto(m *pb.MessageInfo) *apiresource.Actor

SenderActorFromProto builds the displayed sender actor: the branded "Customer Service" alias when the message was collapsed for a customer viewer, otherwise the authoring user or agent. Nil for pure system messages.

func StashConversationLinkMeta

func StashConversationLinkMeta(ctx context.Context, l *pb.ConversationLinkInfo, d *apiresource.ConversationLink)

StashConversationLinkMeta stashes the link's conversation FK so ?include=conversation fetches the full conversation by id via the chat batch loader (which in turn stashes the conversation's own sub-objects, letting conversation.* recurse).

func StashConversationMeta

func StashConversationMeta(ctx context.Context, c *pb.ConversationInfo, d *apiresource.Conversation)

StashConversationMeta builds the conversation's expandable sub-objects (assignee, group, topic, participants, last_message) and stashes them in the request LoadMeta so the include resolver can attach them.

func StashMessageMeta

func StashMessageMeta(ctx context.Context, m *pb.MessageInfo, d *apiresource.Message)

StashMessageMeta builds the message's expandable sub-objects (sender, author, resource, attachments) plus the conversation/reply_to foreign keys and stashes them in the request LoadMeta for the include resolver. Sender/author actors carry id + type only; names are hydrated downstream.

func TsToPtr

func TsToPtr(ts *timestamppb.Timestamp) *time.Time

TsToPtr converts a proto timestamp to *time.Time (nil when absent).

func TsToTime

func TsToTime(ts *timestamppb.Timestamp) time.Time

TsToTime converts a proto timestamp to time.Time (zero value when nil).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL