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 "errors"
5 "gorm.io/gorm"
6)
7
8func (s *Application) FallbackCoordinator(tx *gorm.DB, actor Actor, b BindingRecord) (BindingRecord, error) {
9 // Never move an admitted turn to another account while it may still run.
10 var active int64
11 if b.ID != "" {
12 if err := tx.Table("coordinator_turns t").Where("t.binding_id=? AND t.attempt_id IN (SELECT id FROM attempts WHERE containment='pending')", b.ID).Count(&active).Error; err != nil {
13 return b, err
14 }
15 if active > 0 {
16 return b, nil
17 }
18 }
19 if b.ID != "" {
20 if err := s.loginNotes(tx, actor, b); err != nil {
21 return b, err
22 }
23 }
24 _, err := s.BindingSelection(tx, b)
25 if b.ID != "" && err != nil && !errors.Is(err, s.WaitingConnection) && !errors.Is(err, s.Forbidden) {
26 return b, err
27 }
28 next, note, err := s.autoCoordinator(tx, actor)
29 if errors.Is(err, s.Conflict) {
30 return b, nil
31 }
32 if err != nil {
33 return b, err
34 }
35 if next.ID == "" {
36 if note != "" && b.ID != "" {
37 var main Main
38 if err = tx.Where("person=? AND team_id=?", actor.Address, b.TeamID).Take(&main).Error; err != nil {
39 return b, err
40 }
41 if err = s.humanNote(tx, actor, main.ID, note); err != nil {
42 return b, err
43 }
44 }
45 return b, nil
46 }
47 return next, nil
48}
49