|
| 1 | +# Getting Started |
| 2 | + |
| 3 | +## Installation |
| 4 | + |
| 5 | +PushBits is meant to be self-hosted. |
| 6 | +That means you have to install it on your own server. |
| 7 | +You are advised to install PushBits behind a reverse proxy and enable TLS. |
| 8 | + |
| 9 | +Currently, the only supported way of installing PushBits is via [Docker](https://www.docker.com/) or [Podman](https://podman.io/). |
| 10 | +The image is hosted [via ghcr.io](https://github.com/pushbits/server/pkgs/container/server). |
| 11 | + |
| 12 | +## Configuration |
| 13 | + |
| 14 | +To see what can be configured, have a look at the [config.sample.yml](https://github.com/pushbits/server/blob/master/config.example.yml) file inside the root of the repository. |
| 15 | + |
| 16 | +Settings can optionally be provided via environment variables. |
| 17 | +The name of the environment variable is composed of a starting `PUSHBITS_`, followed by the keys of the setting, all |
| 18 | +joined with `_`. |
| 19 | +As an example, the HTTP port can be provided as an environment variable called `PUSHBITS_HTTP_PORT`. |
| 20 | + |
| 21 | +To get started, here is a Docker Compose file you can use. |
| 22 | +```yaml |
| 23 | +version: '2' |
| 24 | + |
| 25 | +services: |
| 26 | + server: |
| 27 | + image: ghcr.io/pushbits/server:latest |
| 28 | + ports: |
| 29 | + - 8080:8080 |
| 30 | + environment: |
| 31 | + PUSHBITS_DATABASE_DIALECT: 'sqlite3' |
| 32 | + PUSHBITS_ADMIN_MATRIXID: '@your/matrix/username:matrix.org' # The Matrix account on which the admin will receive their notifications. |
| 33 | + PUSHBITS_ADMIN_PASSWORD: 'your/pushbits/password' # The login password of the admin account. Default username is 'admin'. |
| 34 | + PUSHBITS_MATRIX_USERNAME: 'your/matrix/username' # The Matrix account from which notifications are sent to all users. |
| 35 | + PUSHBITS_MATRIX_PASSWORD: 'your/matrix/password' # The password of the above account. |
| 36 | + volumes: |
| 37 | + - /etc/localtime:/etc/localtime:ro |
| 38 | + - /etc/timezone:/etc/timezone:ro |
| 39 | + - ./data:/data |
| 40 | +``` |
| 41 | +
|
| 42 | +In this example, the configuration file would be located at `./data/config.yml` on the host. |
| 43 | +The SQLite database would be written to `./data/pushbits.db`. |
| 44 | +**Don't forget to adjust the permissions** of the `./data` directory, otherwise PushBits will fail to operate. |
| 45 | + |
| 46 | +## Usage |
| 47 | + |
| 48 | +We provide [a little CLI tool called pbcli](https://github.com/PushBits/cli) to make basic API requests to the server. |
| 49 | +It helps you to create new users and applications. |
| 50 | +You will find further instructions in the linked repository. |
| 51 | + |
| 52 | +At the time of writing, there is no fancy GUI built-in, and we're not sure if this is necessary at all. |
| 53 | +Currently, we would like to avoid front end development, so if you want to contribute in this regard we're happy if you reach out! |
| 54 | + |
| 55 | +After you have created a user and an application, you can use the API to send a push notification to your Matrix account. |
| 56 | + |
| 57 | +```bash |
| 58 | +curl \ |
| 59 | + --header "Content-Type: application/json" \ |
| 60 | + --request POST \ |
| 61 | + --data '{"message":"my message","title":"my title"}' \ |
| 62 | + "https://pushbits.example.com/message?token=$PB_TOKEN" |
| 63 | +``` |
| 64 | + |
| 65 | +Note that the token is associated with your application and has to be kept secret. |
| 66 | +You can retrieve the token using [pbcli](https://github.com/PushBits/cli) by running following command. |
| 67 | + |
| 68 | +```bash |
| 69 | +pbcli application show $PB_APPLICATION --url https://pushbits.example.com --username $PB_USERNAME |
| 70 | +``` |
| 71 | + |
| 72 | +### Message options |
| 73 | + |
| 74 | +Messages can be specified in three different syntaxes: |
| 75 | + |
| 76 | +* `text/plain` |
| 77 | +* `text/html` |
| 78 | +* `text/markdown` |
| 79 | + |
| 80 | +To set a specific syntax you need to set the `extras` parameter ([inspired by Gotify's message extras](https://gotify.net/docs/msgextras#clientdisplay)): |
| 81 | + |
| 82 | +```bash |
| 83 | +curl \ |
| 84 | + --header "Content-Type: application/json" \ |
| 85 | + --request POST \ |
| 86 | + --data '{"message":"my message with\n\n**Markdown** _support_.","title":"my title","extras":{"client::display":{"contentType": "text/markdown"}}}' \ |
| 87 | + "https://pushbits.example.com/message?token=$PB_TOKEN" |
| 88 | +``` |
| 89 | + |
| 90 | +HTML content might not be fully rendered in your Matrix client; see the corresponding [Matrix specs](https://spec.matrix.org/unstable/client-server-api/#mroommessage-msgtypes). |
| 91 | +This also holds for Markdown, as it is translated into the corresponding HTML syntax. |
| 92 | + |
| 93 | +### Deleting a Message |
| 94 | + |
| 95 | +You can delete a message, this will send a notification in response to the original message informing you that the message is "deleted". |
| 96 | + |
| 97 | +To delete a message, you need its message ID which is provided as part of the response when you send the message. |
| 98 | +The ID might contain characters not valid in URIs. |
| 99 | +We hence provide an additional `id_url_encoded` field for messages; you can directly use it when deleting a message without performing encoding yourself. |
| 100 | + |
| 101 | +```bash |
| 102 | +curl \ |
| 103 | + --request DELETE \ |
| 104 | + "https://pushbits.example.com/message/${MESSAGE_ID}?token=$PB_TOKEN" |
| 105 | +``` |
0 commit comments