Download this file
| 1 | package chat |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | |
| 6 | "amadan.net/oficina/equipo/internal/wire" |
| 7 | ) |
| 8 | |
| 9 | // Presentation facts are bound to the accepted Engineering attempt. They |
| 10 | // never enter acceptFacts or mergegate's inputs. |
| 11 | func acceptChangeFiles(l Lease, role string, s stepRecord, f *wire.ChangeFiles) string { |
| 12 | if l.Protocol < wire.ProtocolChangeFiles || role != wire.RolePrimary && role != wire.RoleWorker || |
| 13 | s.Specialist != wire.SpecialistEngineering || !wire.ValidChangeFiles(f) || |
| 14 | f.Base != s.BaseSHA || f.SHA != s.CandidateSHA { |
| 15 | return "" |
| 16 | } |
| 17 | raw, _ := json.Marshal(f) |
| 18 | return string(raw) |
| 19 | } |
| 20 | |
| 21 | func stepChangeFilesView(s stepRecord) *wire.ChangeFiles { |
| 22 | if s.Specialist != wire.SpecialistEngineering || s.State != wire.StepDone || s.ChangeFiles == "" { |
| 23 | return nil |
| 24 | } |
| 25 | var f wire.ChangeFiles |
| 26 | if json.Unmarshal([]byte(s.ChangeFiles), &f) != nil || !wire.ValidChangeFiles(&f) || |
| 27 | f.Base != s.BaseSHA || f.SHA != s.CandidateSHA { |
| 28 | return nil |
| 29 | } |
| 30 | return &f |
| 31 | } |
| 32 | |