Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
name: Go 1.19
name: Build & Test

on:
push:
branches: [ "main" ]
workflow_dispatch:
pull_request:
branches: [ "main" ]
branches: [main]

jobs:

build:
build-and-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: src/go.mod

- name: Build
run: go build -v .
- name: Build
working-directory: src
run: go build ./...

- name: Test
run: go test -v .
- name: Test
working-directory: src
run: go test ./...
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

.env
.vscode/
.claude/
.claude/fmsgid
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ See .env.example for a list of environment variables which can be copied to a `.
```
GIN_MODE=release
FMSGID_PORT=8080
FMSGID_CSV_FILE=/path/to/addresses.csv
```

| Variable | Description | Default |
|----------|-------------|---------|
| `GIN_MODE` | Gin framework mode (`release`, `debug`, `test`) | `debug` |
| `FMSGID_PORT` | Port to listen on | `8080` |
| `FMSGID_CSV_FILE` | Path to a CSV file to sync addresses from. When set, fmsgid watches the file for changes and automatically syncs the `address` table. When unset, CSV sync is disabled. | _(unset)_ |

## Build

From the `src` directory:
Expand All @@ -34,6 +41,41 @@ PostgreSQL database with tables created from `dd.sql` is required. The database
./fmsgid
```

## CSV Identity Provider

When `FMSGID_CSV_FILE` is set, fmsgid reads the CSV file at startup and watches it for changes using filesystem notifications. On each change the `address` table is synced:

- Addresses in the CSV are **upserted** (created or updated).
- Addresses in the database but **not** in the CSV have `accepting_new` set to `false` (they are not deleted).

The CSV must have a header row. Column names correspond to the `address` table columns. Only the `address` column is required; all others are optional and use the same defaults as the table.

To get started, copy the example file and edit it with your addresses:

```
cp addresses.csv.example addresses.csv
```

Then set `FMSGID_CSV_FILE=addresses.csv` in your `.env` file (or environment).

Comment on lines +53 to +60
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README references an example file named addresses.csv.example, but the repository adds addresses.example.csv. Update the README commands/links to match the actual filename (or rename the example file) so new users can follow the instructions successfully.

Copilot uses AI. Check for mistakes.
Available columns:

| Column | Required | Default | Description |
|--------|----------|---------|-------------|
| `address` | yes | | fmsg address (e.g. `@alice@example.com`) |
| `display_name` | no | _(empty)_ | Display name |
| `accepting_new` | no | `true` | Whether the address accepts new messages |
| `limit_recv_size_total` | no | `102400000` | Total received size limit (bytes) |
| `limit_recv_size_per_msg` | no | `10240` | Max size per received message |
| `limit_recv_size_per_1d` | no | `102400` | Received size limit per day |
| `limit_recv_count_per_1d` | no | `1000` | Received message count limit per day |
| `limit_send_size_total` | no | `102400000` | Total sent size limit |
| `limit_send_size_per_msg` | no | `10240` | Max size per sent message |
| `limit_send_size_per_1d` | no | `102400` | Sent size limit per day |
| `limit_send_count_per_1d` | no | `1000` | Sent message count limit per day |

See `addresses.csv.example` for a complete example with all columns.

## API Routes

All routes are served over HTTPS under the `/fmsgid` path.
Expand Down
3 changes: 3 additions & 0 deletions addresses.example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
address,display_name,accepting_new,limit_recv_size_total,limit_recv_size_per_msg,limit_recv_size_per_1d,limit_recv_count_per_1d,limit_send_size_total,limit_send_size_per_msg,limit_send_size_per_1d,limit_send_count_per_1d
@alice@example.com,Alice,true,102400000,10240,102400,1000,102400000,10240,102400,1000
@bob@example.com,Bob,true,102400000,10240,102400,1000,102400000,10240,102400,1000
16 changes: 8 additions & 8 deletions dd.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ create table if not exists address (
address text not null,
display_name text,
accepting_new bool not null default true,
limit_recv_size_total bigint not null default -1,
limit_recv_size_per_msg bigint not null default -1,
limit_recv_size_per_1d bigint not null default -1,
limit_recv_count_per_1d bigint not null default -1,
limit_send_size_total bigint not null default -1,
limit_send_size_per_msg bigint not null default -1,
limit_send_size_per_1d bigint not null default -1,
limit_send_count_per_1d bigint not null default -1
limit_recv_size_total bigint not null default 102400000,
limit_recv_size_per_msg bigint not null default 10240,
limit_recv_size_per_1d bigint not null default 102400,
limit_recv_count_per_1d bigint not null default 1000,
limit_send_size_total bigint not null default 102400000,
limit_send_size_per_msg bigint not null default 10240,
limit_send_size_per_1d bigint not null default 102400,
limit_send_count_per_1d bigint not null default 1000
Comment on lines 13 to +21
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dd.sql changes the default quota limits from -1 to fixed positive values, but the new CSV sync path (parseCSV) still defaults unspecified limits to -1 and the README/example file still document -1 defaults. Please align schema defaults, CSV parsing defaults, and documentation so a missing column in the CSV results in the intended quota values.

Copilot uses AI. Check for mistakes.
);

create table if not exists address_tx (
Expand Down
Loading
Loading