+8
automod/engine/context.go
+8
automod/engine/context.go
···
242
242
c.effects.AddAccountLabel(val)
243
243
}
244
244
245
+
func (c *AccountContext) RemoveAccountLabel(val string) {
246
+
c.effects.RemoveAccountLabel(val)
247
+
}
248
+
245
249
func (c *AccountContext) AddAccountTag(val string) {
246
250
c.effects.AddAccountTag(val)
247
251
}
···
268
272
269
273
func (c *RecordContext) AddRecordLabel(val string) {
270
274
c.effects.AddRecordLabel(val)
275
+
}
276
+
277
+
func (c *RecordContext) RemoveRecordLabel(val string) {
278
+
c.effects.RemoveRecordLabel(val)
271
279
}
272
280
273
281
func (c *RecordContext) AddRecordTag(val string) {
+28
automod/engine/effects.go
+28
automod/engine/effects.go
···
28
28
CounterDistinctIncrements []CounterDistinctRef // TODO: better variable names
29
29
// Label values which should be applied to the overall account, as a result of rule execution.
30
30
AccountLabels []string
31
+
// Label values which should be removed from the overall account, as a result of rule execution.
32
+
RemovedAccountLabels []string
31
33
// Moderation tags (similar to labels, but private) which should be applied to the overall account, as a result of rule execution.
32
34
AccountTags []string
33
35
// automod flags (metadata) which should be applied to the account as a result of rule execution.
···
42
44
AccountAcknowledge bool
43
45
// Same as "AccountLabels", but at record-level
44
46
RecordLabels []string
47
+
// Same as "RemovedRecordLabels", but at record-level
48
+
RemovedRecordLabels []string
45
49
// Same as "AccountTags", but at record-level
46
50
RecordTags []string
47
51
// Same as "AccountFlags", but at record-level
···
98
102
e.AccountLabels = append(e.AccountLabels, val)
99
103
}
100
104
105
+
// Enqueues the provided label (string value) to be removed from the account at the end of rule processing.
106
+
func (e *Effects) RemoveAccountLabel(val string) {
107
+
e.mu.Lock()
108
+
defer e.mu.Unlock()
109
+
for _, v := range e.RemovedRecordLabels {
110
+
if v == val {
111
+
return
112
+
}
113
+
}
114
+
e.RemovedAccountLabels = append(e.RemovedAccountLabels, val)
115
+
}
116
+
101
117
// Enqueues the provided label (string value) to be added to the account at the end of rule processing.
102
118
func (e *Effects) AddAccountTag(val string) {
103
119
e.mu.Lock()
···
162
178
}
163
179
}
164
180
e.RecordLabels = append(e.RecordLabels, val)
181
+
}
182
+
183
+
// Enqueues the provided label (string value) to be removed from the record at the end of rule processing.
184
+
func (e *Effects) RemoveRecordLabel(val string) {
185
+
e.mu.Lock()
186
+
defer e.mu.Unlock()
187
+
for _, v := range e.RemovedRecordLabels {
188
+
if v == val {
189
+
return
190
+
}
191
+
}
192
+
e.RemovedRecordLabels = append(e.RemovedRecordLabels, val)
165
193
}
166
194
167
195
// Enqueues the provided tag (string value) to be added to the record at the end of rule processing.