-
Notifications
You must be signed in to change notification settings - Fork 0
CSV #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSV #1
Changes from all commits
12b1526
1f69b2b
56b7107
ee09940
71f2e2c
39fe331
6b6d772
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 ./... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,4 @@ | |
|
|
||
| .env | ||
| .vscode/ | ||
| .claude/ | ||
| .claude/fmsgid | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
|
@@ -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). | ||
|
|
||
| Available columns: | ||
|
|
||
| | Column | Required | Default | Description | | ||
| |--------|----------|---------|-------------| | ||
| | `address` | yes | | fmsg address (e.g. `@[email protected]`) | | ||
| | `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. | ||
|
|
||
| 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 | ||
| @[email protected],Alice,true,102400000,10240,102400,1000,102400000,10240,102400,1000 | ||
| @[email protected],Bob,true,102400000,10240,102400,1000,102400000,10240,102400,1000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
| ); | ||
|
|
||
| create table if not exists address_tx ( | ||
|
|
||
There was a problem hiding this comment.
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 addsaddresses.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.