diff options
Diffstat (limited to 'bug/snapshot.go')
-rw-r--r-- | bug/snapshot.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bug/snapshot.go b/bug/snapshot.go index a4661b14..114b1123 100644 --- a/bug/snapshot.go +++ b/bug/snapshot.go @@ -54,6 +54,11 @@ func (snap *Snapshot) LastEditUnix() int64 { return snap.Operations[len(snap.Operations)-1].GetUnixTime() } +// GetCreateMetadata return the creation metadata +func (snap *Snapshot) GetCreateMetadata(key string) (string, bool) { + return snap.Operations[0].GetMetadata(key) +} + // SearchTimelineItem will search in the timeline for an item matching the given hash func (snap *Snapshot) SearchTimelineItem(hash git.Hash) (TimelineItem, error) { for i := range snap.Timeline { @@ -87,5 +92,45 @@ func (snap *Snapshot) addParticipant(participant identity.Interface) { snap.Participants = append(snap.Participants, participant) } +// HasParticipant return true if the id is a participant +func (snap *Snapshot) HasParticipant(id string) bool { + for _, p := range snap.Participants { + if p.Id() == id { + return true + } + } + return false +} + +// HasAnyParticipant return true if one of the ids is a participant +func (snap *Snapshot) HasAnyParticipant(ids ...string) bool { + for _, id := range ids { + if snap.HasParticipant(id) { + return true + } + } + return false +} + +// HasActor return true if the id is a actor +func (snap *Snapshot) HasActor(id string) bool { + for _, p := range snap.Actors { + if p.Id() == id { + return true + } + } + return false +} + +// HasAnyActor return true if one of the ids is a actor +func (snap *Snapshot) HasAnyActor(ids ...string) bool { + for _, id := range ids { + if snap.HasActor(id) { + return true + } + } + return false +} + // Sign post method for gqlgen func (snap *Snapshot) IsAuthored() {} |