oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "context"
5 "errors"
6
7 "amadan.net/oficina/equipo/internal/equipo/conversation"
8 "amadan.net/oficina/equipo/internal/equipo/kernel"
9 "gorm.io/gorm"
10)
11
12type Mutation = kernel.Mutation
13type Message = conversation.Message
14type Card = conversation.Card
15type ConversationPage = conversation.ConversationPage
16
17//lint:ignore ST1005 User-facing errors preserve the pending sentence in copy.go.
18var ErrCursorExpired = errors.New(copyConversationCursorExpired)
19
20func conversationAuthority(tx *gorm.DB, actor Actor) (string, error) {
21 if _, err := currentRunnerMember(tx, actor.Address); err != nil {
22 return "", err
23 }
24 var instance Team
25 if err := tx.First(&instance).Error; err != nil {
26 return "", storeError(err)
27 }
28 return instance.ID, nil
29}
30func conversationAt(tx *gorm.DB) *conversation.Store {
31 return conversation.New(tx, conversation.Dependencies{
32 Authorize: conversationAuthority, CoordinatorAudit: coordinatorAudit,
33 Task: conversation.TaskLookup(conversationAuthority, ErrNotFound),
34 Audit: appendAudit, NotFound: ErrNotFound, Conflict: ErrConflict, Invalid: ErrInvalid, CursorExpired: ErrCursorExpired, RoutedCopy: pageCopy["conversation.routed"], ProposedCopy: copyText("plan.proposed"),
35 })
36}
37func (s *Store) Conversation(ctx context.Context, a Actor, cursor string, limit int) (ConversationPage, error) {
38 return s.coordinatorApplication().ConversationPage(ctx, a, cursor, limit)
39}
40func (s *Store) SendMessage(ctx context.Context, a Actor, thread, body string, m Mutation) (Message, error) {
41 return s.coordinatorApplication().SendMessage(ctx, a, thread, body, m)
42}
43func (s *Store) TaskThread(ctx context.Context, a Actor, task, cursor string, limit int) (ConversationPage, error) {
44 return s.coordinatorApplication().TaskThread(ctx, a, task, cursor, limit)
45}
46func (s *Store) RouteMessage(ctx context.Context, a Actor, message, task string, m Mutation) (Message, error) {
47 return s.coordinatorApplication().RouteMessage(ctx, a, message, task, m)
48}
49