+23
-2
appview/state/knotstream.go
+23
-2
appview/state/knotstream.go
···
71
71
if err != nil {
72
72
return err
73
73
}
74
-
75
74
if !slices.Contains(knownKnots, source.Knot) {
76
75
return fmt.Errorf("%s does not belong to %s, something is fishy", record.CommitterDid, source.Knot)
77
76
}
78
77
78
+
knownEmails, err := db.GetAllEmails(d, record.CommitterDid)
79
+
if err != nil {
80
+
return err
81
+
}
82
+
count := 0
83
+
for _, ke := range knownEmails {
84
+
if record.Meta == nil {
85
+
continue
86
+
}
87
+
if record.Meta.CommitCount == nil {
88
+
continue
89
+
}
90
+
for _, ce := range record.Meta.CommitCount.ByEmail {
91
+
if ce == nil {
92
+
continue
93
+
}
94
+
if ce.Email == ke.Address {
95
+
count += int(ce.Count)
96
+
}
97
+
}
98
+
}
99
+
79
100
punch := db.Punch{
80
101
Did: record.CommitterDid,
81
102
Date: time.Now(),
82
-
Count: 1,
103
+
Count: count,
83
104
}
84
105
if err := db.AddPunch(d, punch); err != nil {
85
106
return err