openvibers/openvibe.chat Commits
The /paste chat command links the paste on OpenVibe.Community directly; SITE_URL removed (#22)
Changes
@@@ -80,9 +80,6 @@ LIVE_MIRROR=0# Where Events delivers (default http://127.0.0.1:$PORT/internal/events)#CHAT_EVENTS_ENDPOINT=http://127.0.0.1:4400/internal/events--# Public origin used in /paste links (Live's SITE_URL)--SITE_URL=https://openvibe.live--# Channel sounds: the SAME directory as Live's (stored rows hold absolute paths into it and Live's# donation alerts read alert sounds from it). Production: /opt/openvibe.live/data/soundsSOUNDS_PATH=./data/sounds@@@ -121,7 +121,7 @@ Live data maintained by `live-context` (never authority), `events_outbox`, `live`/etc/openvibe/live.env`.4. **Chat.** `git clone … /opt/openvibe.chat && cd /opt/openvibe.chat && npm ci --omit=dev`;`/etc/openvibe/chat.env` from `.env.example` (0600): `OV_LIVE_INTERNAL_URL`, Network URLs,-- `SITE_URL=https://openvibe.live`, `BASE_URL=https://openvibe.live`, `LIVE_MIRROR=1`, and++ `BASE_URL=https://openvibe.live`, `LIVE_MIRROR=1`, and`EVENTS_URL` if OpenVibe.Events is deployed. The unit sets `CHAT_DB_PATH`, `CHAT_CACHE_DIR`,`SOUNDS_PATH=/opt/openvibe.live/data/sounds` and allows writes there. ffmpeg/ffprobe andespeak-ng are the host's (Live uses the same).@@@ -21,6 +21,7 @@ const WebSocket = require('ws');const fs = require('fs');const crypto = require('crypto');const db = require('../db/database');++const config = require('../config');const ctx = require('../live-context');const { extractWsTokenFrom, countWsCookieUse, wsCookieReliance, authenticateWs } = require('../auth/auth');const session = require('../auth/network-session');@@@ -1813,8 +1814,9 @@ class ChatServer {user_id: userId || undefined,stream_id: client.streamId || undefined,}).then(async (paste) => {-- const siteUrl = process.env.SITE_URL || '';-- const pasteUrl = `${siteUrl}/p/${paste.slug}`;++ // Pastes live on OpenVibe.Community; link there (Chat's configured Community++ // base), not at a Live-origin SITE_URL that only 301s.++ const pasteUrl = `${config.web.communityUrl}/p/${encodeURIComponent(paste.slug)}`;// Show link to everyone in streamawait this._broadcastToRoom(client, {type: 'system',@@@ -197,5 +197,4 @@ module.exports = {},// Where Chat keeps its own caches (101soundboards clips, TTS preview clips).cacheDir: process.env.CHAT_CACHE_DIR || path.join(path.dirname(process.env.CHAT_DB_PATH || './data/chat.db'), 'cache'),-- // (SITE_URL — the public origin in /paste links — is read where Live read it, as in Live.)};@@@ -300,7 +300,6 @@ async function boot({ env = {} } = {}) {OV_LIVE_INTERNAL_URL: `http://127.0.0.1:${livePort}`,LIVE_MIRROR: '0',EVENTS_URL: '',-- SITE_URL: 'https://openvibe.live',...env,});@@@ -281,11 +281,11 @@ t('/tts broadcasts the line to the room', async () => {assert.strictEqual(m.core_username, 'alice');});--t('/paste creates the paste through Live and announces it', async () => {++t('/paste creates the paste through Live and announces the Community link', async () => {await h.sleep(1100);aliceWs.sendJson({ type: 'chat', message: '/paste const x = 1;' });const m = await bobWs.next((x) => x.type === 'system' && /shared a paste/.test(x.message));-- assert.strictEqual(m.message, '📋 Anonymous shared a paste: https://openvibe.live/p/abc123');++ assert.strictEqual(m.message, `📋 Anonymous shared a paste: ${require('../server/config').web.communityUrl}/p/abc123`);const fx = h.live.effects.find((e) => e.name === 'paste');assert.strictEqual(fx.body.content, 'const x = 1;');assert.strictEqual(fx.body.user_id, alice.id);
@@ -80,9 +80,6 @@ LIVE_MIRROR=0
@@ -80,9 +80,6 @@ LIVE_MIRROR=0
# Where Events delivers (default http://127.0.0.1:$PORT/internal/events)
# Where Events delivers (default http://127.0.0.1:$PORT/internal/events)
#CHAT_EVENTS_ENDPOINT=http://127.0.0.1:4400/internal/events
#CHAT_EVENTS_ENDPOINT=http://127.0.0.1:4400/internal/events
-# Public origin used in /paste links (Live's SITE_URL)
-SITE_URL=https://openvibe.live
-
# Channel sounds: the SAME directory as Live's (stored rows hold absolute paths into it and Live's
# Channel sounds: the SAME directory as Live's (stored rows hold absolute paths into it and Live's
# donation alerts read alert sounds from it). Production: /opt/openvibe.live/data/sounds
# donation alerts read alert sounds from it). Production: /opt/openvibe.live/data/sounds
SOUNDS_PATH=./data/sounds
SOUNDS_PATH=./data/sounds
@@ -121,7 +121,7 @@ Live data maintained by `live-context` (never authority), `events_outbox`, `live
@@ -121,7 +121,7 @@ Live data maintained by `live-context` (never authority), `events_outbox`, `live
`/etc/openvibe/live.env`.
`/etc/openvibe/live.env`.
4. **Chat.** `git clone … /opt/openvibe.chat && cd /opt/openvibe.chat && npm ci --omit=dev`;
4. **Chat.** `git clone … /opt/openvibe.chat && cd /opt/openvibe.chat && npm ci --omit=dev`;
`/etc/openvibe/chat.env` from `.env.example` (0600): `OV_LIVE_INTERNAL_URL`, Network URLs,
`/etc/openvibe/chat.env` from `.env.example` (0600): `OV_LIVE_INTERNAL_URL`, Network URLs,
- `SITE_URL=https://openvibe.live`, `BASE_URL=https://openvibe.live`, `LIVE_MIRROR=1`, and
+ `BASE_URL=https://openvibe.live`, `LIVE_MIRROR=1`, and
`EVENTS_URL` if OpenVibe.Events is deployed. The unit sets `CHAT_DB_PATH`, `CHAT_CACHE_DIR`,
`EVENTS_URL` if OpenVibe.Events is deployed. The unit sets `CHAT_DB_PATH`, `CHAT_CACHE_DIR`,
`SOUNDS_PATH=/opt/openvibe.live/data/sounds` and allows writes there. ffmpeg/ffprobe and
`SOUNDS_PATH=/opt/openvibe.live/data/sounds` and allows writes there. ffmpeg/ffprobe and
espeak-ng are the host's (Live uses the same).
espeak-ng are the host's (Live uses the same).
@@ -21,6 +21,7 @@ const WebSocket = require('ws');
@@ -21,6 +21,7 @@ const WebSocket = require('ws');
const fs = require('fs');
const fs = require('fs');
const crypto = require('crypto');
const crypto = require('crypto');
const db = require('../db/database');
const db = require('../db/database');
+const config = require('../config');
const ctx = require('../live-context');
const ctx = require('../live-context');
const { extractWsTokenFrom, countWsCookieUse, wsCookieReliance, authenticateWs } = require('../auth/auth');
const { extractWsTokenFrom, countWsCookieUse, wsCookieReliance, authenticateWs } = require('../auth/auth');
const session = require('../auth/network-session');
const session = require('../auth/network-session');
@@ -1813,8 +1814,9 @@ class ChatServer {
@@ -1813,8 +1814,9 @@ class ChatServer {
user_id: userId || undefined,
user_id: userId || undefined,
stream_id: client.streamId || undefined,
stream_id: client.streamId || undefined,
}).then(async (paste) => {
}).then(async (paste) => {
- const siteUrl = process.env.SITE_URL || '';
- const pasteUrl = `${siteUrl}/p/${paste.slug}`;
+ // Pastes live on OpenVibe.Community; link there (Chat's configured Community
+ // base), not at a Live-origin SITE_URL that only 301s.
+ const pasteUrl = `${config.web.communityUrl}/p/${encodeURIComponent(paste.slug)}`;
// Show link to everyone in stream
// Show link to everyone in stream
await this._broadcastToRoom(client, {
await this._broadcastToRoom(client, {
type: 'system',
type: 'system',
@@ -197,5 +197,4 @@ module.exports = {
@@ -197,5 +197,4 @@ module.exports = {
},
},
// Where Chat keeps its own caches (101soundboards clips, TTS preview clips).
// Where Chat keeps its own caches (101soundboards clips, TTS preview clips).
cacheDir: process.env.CHAT_CACHE_DIR || path.join(path.dirname(process.env.CHAT_DB_PATH || './data/chat.db'), 'cache'),
cacheDir: process.env.CHAT_CACHE_DIR || path.join(path.dirname(process.env.CHAT_DB_PATH || './data/chat.db'), 'cache'),
- // (SITE_URL — the public origin in /paste links — is read where Live read it, as in Live.)
};
};
@@ -300,7 +300,6 @@ async function boot({ env = {} } = {}) {
@@ -300,7 +300,6 @@ async function boot({ env = {} } = {}) {
OV_LIVE_INTERNAL_URL: `http://127.0.0.1:${livePort}`,
OV_LIVE_INTERNAL_URL: `http://127.0.0.1:${livePort}`,
LIVE_MIRROR: '0',
LIVE_MIRROR: '0',
EVENTS_URL: '',
EVENTS_URL: '',
- SITE_URL: 'https://openvibe.live',
...env,
...env,
});
});
@@ -281,11 +281,11 @@ t('/tts broadcasts the line to the room', async () => {
@@ -281,11 +281,11 @@ t('/tts broadcasts the line to the room', async () => {
assert.strictEqual(m.core_username, 'alice');
assert.strictEqual(m.core_username, 'alice');
});
});
-t('/paste creates the paste through Live and announces it', async () => {
+t('/paste creates the paste through Live and announces the Community link', async () => {
await h.sleep(1100);
await h.sleep(1100);
aliceWs.sendJson({ type: 'chat', message: '/paste const x = 1;' });
aliceWs.sendJson({ type: 'chat', message: '/paste const x = 1;' });
const m = await bobWs.next((x) => x.type === 'system' && /shared a paste/.test(x.message));
const m = await bobWs.next((x) => x.type === 'system' && /shared a paste/.test(x.message));
- assert.strictEqual(m.message, '📋 Anonymous shared a paste: https://openvibe.live/p/abc123');
+ assert.strictEqual(m.message, `📋 Anonymous shared a paste: ${require('../server/config').web.communityUrl}/p/abc123`);
const fx = h.live.effects.find((e) => e.name === 'paste');
const fx = h.live.effects.find((e) => e.name === 'paste');
assert.strictEqual(fx.body.content, 'const x = 1;');
assert.strictEqual(fx.body.content, 'const x = 1;');
assert.strictEqual(fx.body.user_id, alice.id);
assert.strictEqual(fx.body.user_id, alice.id);