Skip to content

Commit fb82f7d

Browse files
committed
improve chat notes
1 parent cd114be commit fb82f7d

1 file changed

Lines changed: 88 additions & 8 deletions

File tree

src/content/docs/developers/chats.mdx

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ Other Hive apps can call Ecency's `/api/mattermost/*` routes directly - **no Mat
2222
- **Cookies required**: The routes rely on an httpOnly `mm_pat` cookie. When calling from a browser, use `credentials: "include"` so the cookie is stored for subsequent requests.
2323
- **Hive access tokens only**: Your app never needs Mattermost credentials. Provide the user's Hive `accessToken`/`refreshToken` and username to bootstrap; the Ecency backend handles PAT creation and all proxying.
2424

25-
If you self-host Ecency, set these variables in your `.env` (see `apps/web/.env.template`):
26-
27-
- `MATTERMOST_BASE_URL`: Mattermost server REST base (e.g., `https://mattermost.example.com/api/v4`).
28-
- `MATTERMOST_ADMIN_TOKEN`: Admin personal access token used to provision users, teams, and channels.
29-
- `MATTERMOST_TEAM_ID`: Team id where chat channels live.
30-
31-
These are required only when running the Ecency API yourself; consumers of `ecency.com/api/mattermost` do not need them.
32-
3325
## Quickstart for Hive app integrators
3426

3527
1. **Collect Hive tokens**: Obtain the user's Ecency/Hive `accessToken` or `refreshToken` (JWT) plus the Hive `username` after login in your app.
@@ -121,3 +113,91 @@ All routes live under `/api/mattermost` and expect the `mm_pat` cookie set by th
121113

122114
- PAT cookies are httpOnly, `sameSite=lax`, and secured in production. Avoid exposing admin tokens client-side; all Mattermost admin operations stay server-side.
123115
- Hive JWT validation ensures only the authenticated Hive account can bootstrap and obtain a chat PAT tied to their username.
116+
117+
## Self-host / Ecency instances
118+
119+
If you self-host Ecency, set these variables in your `.env` (see `apps/web/.env.template`):
120+
121+
- `MATTERMOST_BASE_URL`: Mattermost server REST base (e.g., `https://mattermost.example.com/api/v4`).
122+
- `MATTERMOST_ADMIN_TOKEN`: Admin personal access token used to provision users, teams, and channels.
123+
- `MATTERMOST_TEAM_ID`: Team id where chat channels live.
124+
125+
If you're self-hosting the Mattermost **Team Edition (community edition)** for development, you can start with a simple `docker-compose.yml` like:
126+
127+
```yaml
128+
version: '3.8'
129+
130+
services:
131+
db:
132+
image: postgres:15
133+
restart: always
134+
environment:
135+
POSTGRES_USER: mattermost
136+
POSTGRES_PASSWORD: chat_password
137+
POSTGRES_DB: mattermost
138+
volumes:
139+
- db_data:/var/lib/postgresql/data
140+
141+
mattermost:
142+
image: mattermost/mattermost-team-edition:10.11
143+
restart: always
144+
depends_on:
145+
- db
146+
ports:
147+
- "8065:8065"
148+
environment:
149+
MM_SQLSETTINGS_DRIVERNAME: postgres
150+
MM_SQLSETTINGS_DATASOURCE: postgres://mattermost:chat_password@db:5432/mattermost?sslmode=disable&connect_timeout=10
151+
MM_SERVICESETTINGS_SITEURL: https://chat.ecency.com
152+
MM_SERVICESETTINGS_LISTENADDRESS: :8065
153+
MM_LOGSETTINGS_ENABLECONSOLE: "true"
154+
MM_FILESETTINGS_DRIVERNAME: local
155+
MM_FILESETTINGS_DIRECTORY: /mattermost/data
156+
MM_EMAILSETTINGS_SMTPSERVER: mail.ecency.com
157+
MM_EMAILSETTINGS_SMTPPORT: "587"
158+
MM_EMAILSETTINGS_SMTPUSERNAME: noreply@ecency.com
159+
MM_EMAILSETTINGS_SMTPPASSWORD: email_password
160+
MM_EMAILSETTINGS_ENABLESMTPAUTH: "true"
161+
MM_EMAILSETTINGS_ENABLESECURESMTP: "true"
162+
MM_EMAILSETTINGS_REQUIREEMAILVERIFICATION: "false"
163+
MM_SERVICESETTINGS_ENABLEGIFS: "false"
164+
MM_SERVICESETTINGS_ENABLEOPENGRAPH: "false"
165+
volumes:
166+
- app_data:/mattermost/data
167+
labels:
168+
- "traefik.enable=true"
169+
- "traefik.http.routers.mm.rule=Host(`chat.ecency.com`)"
170+
- "traefik.http.routers.mm.entrypoints=websecure"
171+
- "traefik.http.routers.mm.tls=true"
172+
- "traefik.http.routers.mm.tls.certresolver=le"
173+
- "traefik.http.services.mm.loadbalancer.server.port=8065"
174+
175+
reverse-proxy:
176+
image: traefik:v3.0
177+
restart: always
178+
command:
179+
- "--providers.docker=true"
180+
- "--entrypoints.web.address=:80"
181+
- "--entrypoints.websecure.address=:443"
182+
- "--certificatesresolvers.le.acme.httpchallenge=true"
183+
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
184+
- "--certificatesresolvers.le.acme.email=hello@ecency.com"
185+
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
186+
ports:
187+
- "80:80"
188+
- "443:443"
189+
volumes:
190+
- /var/run/docker.sock:/var/run/docker.sock:ro
191+
- traefik_data:/letsencrypt
192+
labels:
193+
- "traefik.enable=true"
194+
195+
volumes:
196+
db_data:
197+
app_data:
198+
traefik_data:
199+
```
200+
201+
Update `MM_SERVICESETTINGS_SITEURL`, SMTP values, and Traefik host/ACME email to match your environment. The exposed `8065` port allows direct Mattermost access; you can remove it if you only want Traefik handling ingress.
202+
203+
THESE ARE REQUIRED ONLY when running the Ecency API/instance yourself; consumers of `ecency.com/api/mattermost` or **Hive app integrators** DO NOT NEED them.

0 commit comments

Comments
 (0)