oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package conversation
2
3import (
4 "amadan.net/oficina/equipo/internal/equipo/kernel"
5 "amadan.net/oficina/equipo/internal/runnerproto"
6 "errors"
7 "gorm.io/gorm"
8)
9
10func (s *Store) DeliverCoordinator(row TurnRecord, body string) error {
11 if len(body) == 0 || len(body) > 16384 {
12 return s.deps.Invalid
13 }
14 if _, err := s.deps.Authorize(s.tx, kernel.Actor{Address: row.Person}); err != nil {
15 return err
16 }
17 _, err := s.appendMessage(row.ConversationID, row.ConversationID, "", "coordinator", "coordinator:"+row.BindingID, body, "delivery")
18 return err
19}
20
21func (e *Engine) projects(tx *gorm.DB, person string, sel runnerproto.Selection) ([]runnerproto.CoordinatorProject, error) {
22 var rows []struct {
23 ID, Revision int64
24 Name string
25 }
26 if err := tx.Table("projects").Select("id", "revision", "name").Order("id").Limit(1000).Find(&rows).Error; err != nil {
27 return nil, err
28 }
29 out := []runnerproto.CoordinatorProject{}
30 for _, p := range rows {
31 revision, err := e.CheckProject(tx, person, p.ID, sel)
32 if err != nil {
33 if errors.Is(err, e.Forbidden) || errors.Is(err, e.NotFound) {
34 continue
35 }
36 return nil, err
37 }
38 out = append(out, runnerproto.CoordinatorProject{ID: p.ID, Label: p.Name, Revision: revision})
39 }
40 return out, nil
41}
42