Fix false repeat flags, add repeat-sends setting, limit holiday animations
Message filter: - Ignore copies of a message already seen (same sender, text and send second). Switching between companions re-synced messages the first one had delivered; they missed per-radio storage dedup and were flagged as repeats. - Exempt replies and @[name] mentions from repeat detection. - New "Sends to count as a repeat" setting (2-5, default 2). Each send must fall within 10 minutes of the previous one. - Translations for the new strings in all locales. Holiday animations: - Only one plays at a time; greetings arriving while one is playing or within 5 seconds after it ends are dropped, not queued. - Christmas map "self" marker: Santa hat was upside down.
This commit is contained in:
1 parent
59e571fb20
commit
ddf0b9f553
52 files changed
+526
-24
No files matched your search
@@ -27,6 +27,56 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('sameSenderSends sets which send in a row is flagged', () {
|
||||
final tracker = DuplicateTracker();
|
||||
const text = 'Anyone on the hill repeater?';
|
||||
FilterReason? send(int minutes) => tracker.check(
|
||||
channelId: 'c',
|
||||
sender: 'Bob',
|
||||
text: text,
|
||||
at: t0.add(Duration(minutes: minutes)),
|
||||
sameSenderSends: 3,
|
||||
);
|
||||
expect(send(0), isNull);
|
||||
// Re-sent because nobody answered.
|
||||
expect(send(4), isNull);
|
||||
expect(send(9), FilterReason.duplicate);
|
||||
// A slow flood keeps the run going: each send is within the window of
|
||||
// the previous one.
|
||||
expect(send(17), FilterReason.duplicate);
|
||||
expect(send(25), FilterReason.duplicate);
|
||||
});
|
||||
|
||||
test('the same message seen again is never a repeat', () {
|
||||
final tracker = DuplicateTracker();
|
||||
const text = 'Gday from Brunkerville, how is everyone';
|
||||
// Another companion syncing messages the first one already delivered:
|
||||
// same sender, text and send second, arriving later.
|
||||
for (var i = 0; i < 5; i++) {
|
||||
expect(
|
||||
tracker.check(
|
||||
channelId: 'c',
|
||||
sender: 'VK2WSL TRACKER',
|
||||
text: text,
|
||||
at: t0,
|
||||
receivedAt: t0.add(Duration(minutes: i)),
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
}
|
||||
// Copies are not counted: a real re-send is only the second send.
|
||||
expect(
|
||||
tracker.check(
|
||||
channelId: 'c',
|
||||
sender: 'VK2WSL TRACKER',
|
||||
text: text,
|
||||
at: t0.add(const Duration(minutes: 2)),
|
||||
sameSenderSends: 3,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('short replies repeated by the same sender are not duplicates', () {
|
||||
final tracker = DuplicateTracker();
|
||||
for (final text in ['ok', 'test', 'yes sir', 'ok']) {
|
||||
|
||||
@@ -204,8 +204,10 @@ void main() {
|
||||
|
||||
test('duplicates setting off still records but does not filter', () async {
|
||||
await service.updateSettings(service.settings.copyWith(duplicates: false));
|
||||
expect(eval('a', 'meet at the park'), isNull);
|
||||
expect(eval('a', 'meet at the park'), isNull);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
expect(eval('a', 'meet at the park'), isNull);
|
||||
now = now.add(const Duration(minutes: 1));
|
||||
}
|
||||
await service.updateSettings(service.settings.copyWith(duplicates: true));
|
||||
expect(eval('a', 'meet at the park')?.reason, FilterReason.duplicate);
|
||||
});
|
||||
@@ -216,13 +218,55 @@ void main() {
|
||||
eval('a', 'buy cheap radios here now')?.reason,
|
||||
FilterReason.textRule,
|
||||
);
|
||||
now = now.add(const Duration(minutes: 1));
|
||||
expect(
|
||||
eval('a', 'buy cheap radios here now')?.reason,
|
||||
FilterReason.textRule,
|
||||
);
|
||||
await service.removeRule('x');
|
||||
now = now.add(const Duration(minutes: 1));
|
||||
expect(
|
||||
eval('a', 'buy cheap radios here now')?.reason,
|
||||
FilterReason.duplicate,
|
||||
);
|
||||
});
|
||||
|
||||
test('repeatSends setting picks which send is flagged', () async {
|
||||
await service.updateSettings(service.settings.copyWith(repeatSends: 3));
|
||||
expect(eval('a', 'meet at the park'), isNull);
|
||||
now = now.add(const Duration(minutes: 1));
|
||||
expect(eval('a', 'meet at the park'), isNull);
|
||||
now = now.add(const Duration(minutes: 1));
|
||||
expect(eval('a', 'meet at the park')?.reason, FilterReason.duplicate);
|
||||
});
|
||||
|
||||
test('repeatSends is saved and clamped', () {
|
||||
const settings = MessageFilterSettings(repeatSends: 4);
|
||||
expect(MessageFilterSettings.fromJson(settings.toJson()).repeatSends, 4);
|
||||
expect(MessageFilterSettings.fromJson({}).repeatSends, 2);
|
||||
expect(MessageFilterSettings.fromJson({'repeatSends': 99}).repeatSends, 5);
|
||||
expect(MessageFilterSettings.fromJson({'repeatSends': 0}).repeatSends, 2);
|
||||
});
|
||||
|
||||
test('messages that mention someone are exempt from duplicates', () {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
// Asking several people the same thing.
|
||||
expect(eval('a', '@[Person$i] are you home yet'), isNull);
|
||||
expect(
|
||||
service.evaluate(
|
||||
channelId: _channel,
|
||||
sender: 'b',
|
||||
text: 'did you get my message',
|
||||
isReply: true,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
now = now.add(const Duration(minutes: 1));
|
||||
}
|
||||
// Mentions were not recorded, so the plain text starts fresh.
|
||||
expect(eval('a', 'are you home yet'), isNull);
|
||||
});
|
||||
|
||||
test('not spam exempts duplicates in that channel', () async {
|
||||
eval('a', 'meet at the park');
|
||||
await service.markNotSpam(
|
||||
|
||||
Reference in new issue
Block a user