oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1// Package conversation stores private conversations and shared task discussion.
2// Its operations use the caller's transaction and authority callbacks.
3package conversation
4
5import (
6 "amadan.net/oficina/equipo/internal/equipo/conversation/chatstate"
7 "amadan.net/oficina/equipo/internal/equipo/team"
8 "time"
9)
10
11type Message struct {
12 SourceRefs []team.SourceRef
13 ID, ConversationID, ThreadID, AuthorKind, AuthorID, Body string
14 Sequence, Revision int64
15 CreatedAt time.Time
16}
17type Card = chatstate.Card
18
19type ConversationPage struct {
20 Messages []Message
21 Cards []Card
22 NextCursor string
23 Revision int64
24}
25
26type Main struct {
27 ID string `gorm:"primaryKey"`
28 TeamID string `gorm:"uniqueIndex:conversation_person,priority:1"`
29 Person string `gorm:"uniqueIndex:conversation_person,priority:2"`
30 Revision, LastSequence int64
31}
32
33func (Main) TableName() string { return "conversations" }
34
35type Thread struct {
36 ID string `gorm:"primaryKey"`
37 TaskID string `gorm:"uniqueIndex:conversation_task"`
38 TeamID string
39 Revision, LastSequence int64
40}
41
42func (Thread) TableName() string { return "conversation_threads" }
43
44type messageRecord struct {
45 SourceRefs []team.SourceRef `gorm:"serializer:json"`
46 ID string `gorm:"primaryKey"`
47 StreamID string `gorm:"uniqueIndex:conversation_sequence,priority:1"`
48 Sequence int64 `gorm:"uniqueIndex:conversation_sequence,priority:2"`
49 ConversationID, ThreadID, AuthorKind, AuthorID, Body string
50 Revision int64
51 CreatedAt time.Time
52}
53
54func (messageRecord) TableName() string { return "conversation_messages" }
55func (r messageRecord) message() Message {
56 return Message{SourceRefs: r.SourceRefs, ID: r.ID, ConversationID: r.ConversationID, ThreadID: r.ThreadID, AuthorKind: r.AuthorKind, AuthorID: r.AuthorID, Body: r.Body, Sequence: r.Sequence, Revision: r.Revision, CreatedAt: r.CreatedAt}
57}
58
59type cardRecord struct {
60 ID string `gorm:"primaryKey"`
61 StreamID string `gorm:"index:conversation_card_stream"`
62 Kind, ResourceID string
63 Sequence, Revision int64
64}
65
66func (cardRecord) TableName() string { return "conversation_cards" }
67
68type requestRecord struct {
69 Principal string `gorm:"primaryKey"`
70 Operation string `gorm:"primaryKey"`
71 Resource string `gorm:"primaryKey"`
72 RequestID string `gorm:"primaryKey"`
73 InputHash, Result string
74}
75
76func (requestRecord) TableName() string { return "conversation_requests" }
77
78type routeRecord struct {
79 SourceID string `gorm:"primaryKey"`
80 TaskID, ReplyID, NoticeID string
81}
82
83func (routeRecord) TableName() string { return "conversation_routes" }
84
85type outboxRecord struct {
86 MessageID string `gorm:"primaryKey"`
87 StreamID, Purpose string
88}
89
90func (outboxRecord) TableName() string { return "conversation_outboxes" }
91
92type cursorRecord struct {
93 ID string `gorm:"primaryKey"`
94 Principal, StreamID string
95 After, Through, Revision int64
96 ExpiresAt time.Time
97}
98
99func (cursorRecord) TableName() string { return "conversation_cursors" }
100
101var Models = []any{&ProjectProposal{}, &preferenceRecord{}, &personalSettingsRecord{}, &BindingRecord{}, &TurnRecord{}, &QuestionRecord{}, &Main{}, &Thread{}, &messageRecord{}, &cardRecord{}, &requestRecord{}, &routeRecord{}, &outboxRecord{}, &cursorRecord{}}
102