Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
202fb9cd74 | ||
|
|
76f2635700 | ||
|
|
e2bb299300 | ||
|
|
f5abe9132b | ||
|
|
c6b6d942d4 | ||
|
|
bc0f4e83fc | ||
|
|
5a8a03fb70 | ||
|
|
9c6b037b21 |
@@ -22,14 +22,7 @@ jobs:
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
|
||||
@@ -24,14 +24,7 @@ jobs:
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
@@ -174,14 +167,7 @@ for r in data.get('workflow_runs', []):
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
@@ -232,14 +218,7 @@ for r in data.get('workflow_runs', []):
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
@@ -284,14 +263,7 @@ for r in data.get('workflow_runs', []):
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
@@ -341,14 +313,7 @@ for r in data.get('workflow_runs', []):
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
|
||||
@@ -23,14 +23,7 @@ jobs:
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
@@ -83,14 +76,7 @@ for r in data.get('workflow_runs', []):
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
|
||||
@@ -27,14 +27,7 @@ jobs:
|
||||
created_at=$(curl -sf \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/tasks?limit=100" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
for r in data.get('workflow_runs', []):
|
||||
if r.get('run_number') == $RUN_NUMBER:
|
||||
print(r['created_at'])
|
||||
break
|
||||
" 2>/dev/null)
|
||||
| python3 -c "import sys,json;data=json.load(sys.stdin);rs=[r for r in data.get('workflow_runs',[]) if r.get('run_number')==$RUN_NUMBER];print(rs[0]['created_at'] if rs else '')" 2>/dev/null)
|
||||
if [ -n "$created_at" ]; then
|
||||
queued_epoch=$(date -d "$created_at" +%s)
|
||||
wait_seconds=$((runner_start - queued_epoch))
|
||||
|
||||
+3
-3
@@ -388,7 +388,7 @@ func (m *Ci) Stalwart() *dagger.Service {
|
||||
return dag.Container().
|
||||
From("stalwartlabs/stalwart:v0.14.1").
|
||||
WithFile("/etc/stalwart/config.toml.orig", config).
|
||||
WithExec([]string{"/bin/sh", "-c", "sed -e 's/hostname = \"localhost\"/hostname = \"stalwart\"/' -e 's/bind = \\[\"0.0.0.0:\\([0-9]*\\)\"\\]/bind = [\"0.0.0.0:\\1\", \"[::]:\\1\"]/g' /etc/stalwart/config.toml.orig > /etc/stalwart/config.toml"}).
|
||||
WithExec([]string{"/bin/sh", "-c", "sed -e 's/hostname = \"localhost\"/hostname = \"stalwart\"/' /etc/stalwart/config.toml.orig > /etc/stalwart/config.toml"}).
|
||||
WithDirectory("/tmp/stalwart", dataDir).
|
||||
WithExposedPort(8080). // JMAP
|
||||
WithExposedPort(1430). // IMAP
|
||||
@@ -539,7 +539,7 @@ func (m *Ci) TestBackend(ctx context.Context) (string, error) {
|
||||
return m.WithStalwart(m.setup(m.backendSrc())).
|
||||
WithExec([]string{"/bin/bash", "-c",
|
||||
`tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT; ` +
|
||||
`flutter test --concurrency=1 --reporter expanded --no-pub test/backend >"$tmp" 2>&1 || { cat "$tmp"; exit 1; }; ` +
|
||||
`flutter test --concurrency=1 --reporter expanded --no-pub --exclude-tags=nightly test/backend >"$tmp" 2>&1 || { cat "$tmp"; exit 1; }; ` +
|
||||
`grep -E '^All [0-9]+ tests passed' "$tmp" || tail -1 "$tmp"`}).
|
||||
Stdout(ctx)
|
||||
}
|
||||
@@ -570,7 +570,7 @@ func (m *Ci) ChaosMonkeyBackend(ctx context.Context) (string, error) {
|
||||
return m.WithStalwart(m.setup(m.backendSrc())).
|
||||
WithExec([]string{"/bin/bash", "-c",
|
||||
`tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT; ` +
|
||||
`flutter test test/backend/chaos_monkey_test.dart --reporter expanded --concurrency=1 --no-pub >"$tmp" 2>&1 || { cat "$tmp"; exit 1; }; ` +
|
||||
`flutter test test/backend/chaos_monkey_test.dart --reporter expanded --concurrency=1 --no-pub --tags=nightly >"$tmp" 2>&1 || { cat "$tmp"; exit 1; }; ` +
|
||||
`grep -E '^All [0-9]+ tests passed' "$tmp" || tail -1 "$tmp"`}).
|
||||
Stdout(ctx)
|
||||
}
|
||||
|
||||
@@ -2922,9 +2922,9 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
|
||||
final sql = accountId != null
|
||||
? 'SELECT e.* FROM email_fts f JOIN emails e ON e.rowid = f.rowid'
|
||||
' WHERE email_fts MATCH ? AND e.account_id = ? ORDER BY rank LIMIT 50'
|
||||
' WHERE email_fts MATCH ? AND e.account_id = ? ORDER BY e.received_at DESC LIMIT 50'
|
||||
: 'SELECT e.* FROM email_fts f JOIN emails e ON e.rowid = f.rowid'
|
||||
' WHERE email_fts MATCH ? ORDER BY rank LIMIT 50';
|
||||
' WHERE email_fts MATCH ? ORDER BY e.received_at DESC LIMIT 50';
|
||||
final variables = accountId != null
|
||||
? [Variable<String>(ftsQuery), Variable<String>(accountId)]
|
||||
: [Variable<String>(ftsQuery)];
|
||||
@@ -2942,6 +2942,7 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
for (final e in [...emailRows.map(_toModel), ...noteRows]) {
|
||||
if (seen.add(e.id)) merged.add(e);
|
||||
}
|
||||
merged.sort((a, b) => b.receivedAt.compareTo(a.receivedAt));
|
||||
return merged;
|
||||
}
|
||||
|
||||
@@ -2952,16 +2953,12 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
String? mailboxPath,
|
||||
String query,
|
||||
) async {
|
||||
final words = query
|
||||
.trim()
|
||||
.split(RegExp(r'\s+'))
|
||||
.where((w) => w.isNotEmpty)
|
||||
.toList();
|
||||
final words =
|
||||
query.trim().split(RegExp(r'\s+')).where((w) => w.isNotEmpty).toList();
|
||||
if (words.isEmpty) return [];
|
||||
|
||||
final noteConditions = words.map((_) => 'n.note_text LIKE ?').join(' AND ');
|
||||
final likeVars =
|
||||
words.map((w) => Variable<String>('%$w%')).toList();
|
||||
final likeVars = words.map((w) => Variable<String>('%$w%')).toList();
|
||||
|
||||
final extraConditions = StringBuffer();
|
||||
final extraVars = <Variable<String>>[];
|
||||
@@ -2980,14 +2977,13 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
' WHERE $noteConditions$extraConditions'
|
||||
' ORDER BY e.received_at DESC LIMIT 50';
|
||||
|
||||
final rows = await _db
|
||||
.customSelect(
|
||||
sql,
|
||||
variables: [...likeVars, ...extraVars],
|
||||
readsFrom: {_db.emails, _db.emailNotes},
|
||||
)
|
||||
.get();
|
||||
final emailRows = await Future.wait(rows.map((r) => _db.emails.mapFromRow(r)));
|
||||
final rows = await _db.customSelect(
|
||||
sql,
|
||||
variables: [...likeVars, ...extraVars],
|
||||
readsFrom: {_db.emails, _db.emailNotes},
|
||||
).get();
|
||||
final emailRows =
|
||||
await Future.wait(rows.map((r) => _db.emails.mapFromRow(r)));
|
||||
return emailRows.map(_toModel).toList();
|
||||
}
|
||||
|
||||
@@ -2997,9 +2993,7 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
static String _toFtsQuery(String query) {
|
||||
final words = query
|
||||
.trim()
|
||||
.split(RegExp(r'\s+'))
|
||||
.where((w) => w.isNotEmpty)
|
||||
.map((w) => w.replaceAll(RegExp(r'[^\w]'), ''))
|
||||
.split(RegExp(r'[^\w]+'))
|
||||
.where((w) => w.isNotEmpty)
|
||||
.toList();
|
||||
if (words.isEmpty) return '';
|
||||
@@ -3113,7 +3107,7 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
|
||||
const sql = 'SELECT e.* FROM email_fts f JOIN emails e ON e.rowid = f.rowid'
|
||||
' WHERE email_fts MATCH ? AND e.account_id = ? AND e.mailbox_path = ?'
|
||||
' ORDER BY rank LIMIT 50';
|
||||
' ORDER BY e.received_at DESC LIMIT 50';
|
||||
final variables = [
|
||||
Variable<String>(ftsQuery),
|
||||
Variable<String>(accountId),
|
||||
@@ -3126,14 +3120,14 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
queryRows.map((r) => _db.emails.mapFromRow(r)),
|
||||
);
|
||||
|
||||
final noteRows =
|
||||
await _searchEmailsByNotes(accountId, mailboxPath, query);
|
||||
final noteRows = await _searchEmailsByNotes(accountId, mailboxPath, query);
|
||||
|
||||
final seen = <String>{};
|
||||
final merged = <model.Email>[];
|
||||
for (final e in [...emailRows.map(_toModel), ...noteRows]) {
|
||||
if (seen.add(e.id)) merged.add(e);
|
||||
}
|
||||
merged.sort((a, b) => b.receivedAt.compareTo(a.receivedAt));
|
||||
return merged;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ class _SharedInboxAppState extends ConsumerState<SharedInboxApp> {
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
|
||||
useMaterial3: true,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
@@ -116,6 +117,7 @@ class _SharedInboxAppState extends ConsumerState<SharedInboxApp> {
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
useMaterial3: true,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
),
|
||||
routerConfig: router,
|
||||
);
|
||||
|
||||
@@ -57,6 +57,7 @@ class CrashScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(splashFactory: NoSplash.splashFactory),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Something went wrong'),
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
// CHAOS_ROUNDS (default: 30) — number of random operations to perform
|
||||
// CHAOS_SEED (default: current epoch ms) — seed for reproducibility
|
||||
|
||||
@Tags(['nightly'])
|
||||
library;
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
@@ -132,7 +135,7 @@ void main() {
|
||||
tearDown(() => db.close());
|
||||
|
||||
test('chaos monkey — random operations do not crash the repository',
|
||||
() async {
|
||||
timeout: Timeout.none, () async {
|
||||
final seedStr = _env('CHAOS_SEED');
|
||||
final seed = seedStr.isEmpty
|
||||
? DateTime.now().millisecondsSinceEpoch
|
||||
|
||||
@@ -514,8 +514,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final results =
|
||||
await r.emails.searchEmailsGlobal(null, 'urgent');
|
||||
final results = await r.emails.searchEmailsGlobal(null, 'urgent');
|
||||
expect(results, hasLength(1));
|
||||
expect(results.first.subject, 'Weekly report');
|
||||
});
|
||||
@@ -569,13 +568,76 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final results =
|
||||
await r.emails.searchEmails('acc-1', 'INBOX', 'client');
|
||||
final results = await r.emails.searchEmails('acc-1', 'INBOX', 'client');
|
||||
expect(results, hasLength(1));
|
||||
expect(results.first.subject, 'Project update');
|
||||
expect(results.first.mailboxPath, 'INBOX');
|
||||
});
|
||||
|
||||
test('searchEmailsGlobal returns results sorted by receivedAt descending',
|
||||
() async {
|
||||
final r = _makeRepos();
|
||||
await r.accounts.addAccount(_account, 'pw');
|
||||
|
||||
await r.db.into(r.db.emails).insert(
|
||||
EmailsCompanion.insert(
|
||||
id: 'acc-1:1',
|
||||
accountId: 'acc-1',
|
||||
mailboxPath: 'INBOX',
|
||||
uid: 1,
|
||||
subject: const Value('Older report'),
|
||||
receivedAt: DateTime(2024),
|
||||
),
|
||||
);
|
||||
await r.db.into(r.db.emails).insert(
|
||||
EmailsCompanion.insert(
|
||||
id: 'acc-1:2',
|
||||
accountId: 'acc-1',
|
||||
mailboxPath: 'INBOX',
|
||||
uid: 2,
|
||||
subject: const Value('Newer report'),
|
||||
receivedAt: DateTime(2024, 6),
|
||||
),
|
||||
);
|
||||
|
||||
final results = await r.emails.searchEmailsGlobal(null, 'report');
|
||||
expect(results, hasLength(2));
|
||||
expect(results[0].subject, 'Newer report');
|
||||
expect(results[1].subject, 'Older report');
|
||||
});
|
||||
|
||||
test('searchEmails returns results sorted by receivedAt descending',
|
||||
() async {
|
||||
final r = _makeRepos();
|
||||
await r.accounts.addAccount(_account, 'pw');
|
||||
|
||||
await r.db.into(r.db.emails).insert(
|
||||
EmailsCompanion.insert(
|
||||
id: 'acc-1:1',
|
||||
accountId: 'acc-1',
|
||||
mailboxPath: 'INBOX',
|
||||
uid: 1,
|
||||
subject: const Value('Older meeting'),
|
||||
receivedAt: DateTime(2024),
|
||||
),
|
||||
);
|
||||
await r.db.into(r.db.emails).insert(
|
||||
EmailsCompanion.insert(
|
||||
id: 'acc-1:2',
|
||||
accountId: 'acc-1',
|
||||
mailboxPath: 'INBOX',
|
||||
uid: 2,
|
||||
subject: const Value('Newer meeting'),
|
||||
receivedAt: DateTime(2024, 6),
|
||||
),
|
||||
);
|
||||
|
||||
final results = await r.emails.searchEmails('acc-1', 'INBOX', 'meeting');
|
||||
expect(results, hasLength(2));
|
||||
expect(results[0].subject, 'Newer meeting');
|
||||
expect(results[1].subject, 'Older meeting');
|
||||
});
|
||||
|
||||
test(
|
||||
'searchAddresses returns results sorted by most recently used',
|
||||
() async {
|
||||
|
||||
@@ -50,7 +50,10 @@ Widget _buildScreen({List<Account> accounts = const []}) {
|
||||
FakeAccountRepository(accounts),
|
||||
),
|
||||
],
|
||||
child: const MaterialApp(home: AboutScreen()),
|
||||
child: MaterialApp(
|
||||
theme: ThemeData(splashFactory: NoSplash.splashFactory),
|
||||
home: const AboutScreen(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user