Standardize endpoint name and fix doc. Closes #1966
This commit is contained in:
parent
6ff8c89246
commit
3741196de6
@ -686,7 +686,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
example: https://fediverse.biz/authorize_interaction?uri=https://my.owncast.server/federation/user/streamer
|
example: https://fediverse.biz/authorize_interaction?uri=https://my.owncast.server/federation/user/streamer
|
||||||
|
|
||||||
/api/chat/updatemessagevisibility:
|
/api/chat/messagevisibility:
|
||||||
post:
|
post:
|
||||||
summary: Update the visibility of chat messages.
|
summary: Update the visibility of chat messages.
|
||||||
description: Pass an array of IDs you want to change the chat visibility of.
|
description: Pass an array of IDs you want to change the chat visibility of.
|
||||||
@ -951,7 +951,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|
||||||
/api/admin/chat/updatemessagevisibility:
|
/api/admin/chat/messagevisibility:
|
||||||
post:
|
post:
|
||||||
summary: Update the visibility of chat messages.
|
summary: Update the visibility of chat messages.
|
||||||
description: Pass an array of IDs you want to change the chat visibility of.
|
description: Pass an array of IDs you want to change the chat visibility of.
|
||||||
@ -1984,7 +1984,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|
||||||
/api/integrations/chat/updatemessagevisibility:
|
/api/integrations/chat/messagevisibility:
|
||||||
post:
|
post:
|
||||||
summary: Update the visibility of chat messages.
|
summary: Update the visibility of chat messages.
|
||||||
description: Pass an array of IDs you want to change the chat visibility of.
|
description: Pass an array of IDs you want to change the chat visibility of.
|
||||||
|
@ -126,7 +126,7 @@ func Start() error {
|
|||||||
http.HandleFunc("/api/admin/chat/messages", middleware.RequireAdminAuth(admin.GetChatMessages))
|
http.HandleFunc("/api/admin/chat/messages", middleware.RequireAdminAuth(admin.GetChatMessages))
|
||||||
|
|
||||||
// Update chat message visibility
|
// Update chat message visibility
|
||||||
http.HandleFunc("/api/admin/chat/updatemessagevisibility", middleware.RequireAdminAuth(admin.UpdateMessageVisibility))
|
http.HandleFunc("/api/admin/chat/messagevisibility", middleware.RequireAdminAuth(admin.UpdateMessageVisibility))
|
||||||
|
|
||||||
// Enable/disable a user
|
// Enable/disable a user
|
||||||
http.HandleFunc("/api/admin/chat/users/setenabled", middleware.RequireAdminAuth(admin.UpdateUserEnabled))
|
http.HandleFunc("/api/admin/chat/users/setenabled", middleware.RequireAdminAuth(admin.UpdateUserEnabled))
|
||||||
@ -310,7 +310,7 @@ func Start() error {
|
|||||||
// Inline chat moderation actions
|
// Inline chat moderation actions
|
||||||
|
|
||||||
// Update chat message visibility
|
// Update chat message visibility
|
||||||
http.HandleFunc("/api/chat/updatemessagevisibility", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateMessageVisibility))
|
http.HandleFunc("/api/chat/messagevisibility", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateMessageVisibility))
|
||||||
|
|
||||||
// Enable/disable a user
|
// Enable/disable a user
|
||||||
http.HandleFunc("/api/chat/users/setenabled", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateUserEnabled))
|
http.HandleFunc("/api/chat/users/setenabled", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateUserEnabled))
|
||||||
|
@ -7,112 +7,112 @@ const registerChat = require('./lib/chat').registerChat;
|
|||||||
const sendChatMessage = require('./lib/chat').sendChatMessage;
|
const sendChatMessage = require('./lib/chat').sendChatMessage;
|
||||||
|
|
||||||
const testVisibilityMessage = {
|
const testVisibilityMessage = {
|
||||||
body: 'message ' + Math.floor(Math.random() * 100),
|
body: 'message ' + Math.floor(Math.random() * 100),
|
||||||
type: 'CHAT',
|
type: 'CHAT',
|
||||||
};
|
};
|
||||||
|
|
||||||
var messageId;
|
var messageId;
|
||||||
|
|
||||||
const establishedUserFailedChatMessage = {
|
const establishedUserFailedChatMessage = {
|
||||||
body: 'this message should fail to send ' + Math.floor(Math.random() * 100),
|
body: 'this message should fail to send ' + Math.floor(Math.random() * 100),
|
||||||
type: 'CHAT',
|
type: 'CHAT',
|
||||||
};
|
};
|
||||||
|
|
||||||
test('can send a chat message', async (done) => {
|
test('can send a chat message', async (done) => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
|
|
||||||
sendChatMessage(testVisibilityMessage, accessToken, done);
|
sendChatMessage(testVisibilityMessage, accessToken, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify we can make API call to mark message as hidden', async (done) => {
|
test('verify we can make API call to mark message as hidden', async (done) => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
const ws = new WebSocket(
|
const ws = new WebSocket(
|
||||||
`ws://localhost:8080/ws?accessToken=${accessToken}`,
|
`ws://localhost:8080/ws?accessToken=${accessToken}`,
|
||||||
{
|
{
|
||||||
origin: 'http://localhost:8080',
|
origin: 'http://localhost:8080',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Verify the visibility change comes through the websocket
|
// Verify the visibility change comes through the websocket
|
||||||
ws.on('message', async function incoming(message) {
|
ws.on('message', async function incoming(message) {
|
||||||
const messages = message.split('\n');
|
const messages = message.split('\n');
|
||||||
messages.forEach(async function (message) {
|
messages.forEach(async function (message) {
|
||||||
const event = JSON.parse(message);
|
const event = JSON.parse(message);
|
||||||
|
|
||||||
if (event.type === 'VISIBILITY-UPDATE') {
|
if (event.type === 'VISIBILITY-UPDATE') {
|
||||||
ws.close();
|
ws.close();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await request
|
const res = await request
|
||||||
.get('/api/admin/chat/messages')
|
.get('/api/admin/chat/messages')
|
||||||
.auth('admin', 'abc123')
|
.auth('admin', 'abc123')
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
const message = res.body[0];
|
const message = res.body[0];
|
||||||
messageId = message.id;
|
messageId = message.id;
|
||||||
await request
|
await request
|
||||||
.post('/api/admin/chat/updatemessagevisibility')
|
.post('/api/admin/chat/messagevisibility')
|
||||||
.auth('admin', 'abc123')
|
.auth('admin', 'abc123')
|
||||||
.send({ idArray: [messageId], visible: false })
|
.send({ idArray: [messageId], visible: false })
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify message has become hidden', async (done) => {
|
test('verify message has become hidden', async (done) => {
|
||||||
await new Promise((r) => setTimeout(r, 2000));
|
await new Promise((r) => setTimeout(r, 2000));
|
||||||
|
|
||||||
const res = await request
|
const res = await request
|
||||||
.get('/api/admin/chat/messages')
|
.get('/api/admin/chat/messages')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.auth('admin', 'abc123');
|
.auth('admin', 'abc123');
|
||||||
|
|
||||||
const message = res.body.filter((obj) => {
|
const message = res.body.filter((obj) => {
|
||||||
return obj.id === messageId;
|
return obj.id === messageId;
|
||||||
});
|
});
|
||||||
expect(message.length).toBe(1);
|
expect(message.length).toBe(1);
|
||||||
// expect(message[0].hiddenAt).toBeTruthy();
|
// expect(message[0].hiddenAt).toBeTruthy();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can enable established chat user mode', async (done) => {
|
test('can enable established chat user mode', async (done) => {
|
||||||
await request
|
await request
|
||||||
.post('/api/admin/config/chat/establishedusermode')
|
.post('/api/admin/config/chat/establishedusermode')
|
||||||
.auth('admin', 'abc123')
|
.auth('admin', 'abc123')
|
||||||
.send({ value: true })
|
.send({ value: true })
|
||||||
.expect(200);
|
.expect(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can send a message after established user mode is enabled', async (done) => {
|
test('can send a message after established user mode is enabled', async (done) => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
|
|
||||||
sendChatMessage(establishedUserFailedChatMessage, accessToken, done);
|
sendChatMessage(establishedUserFailedChatMessage, accessToken, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify rejected message is not in the chat feed', async (done) => {
|
test('verify rejected message is not in the chat feed', async (done) => {
|
||||||
const res = await request
|
const res = await request
|
||||||
.get('/api/admin/chat/messages')
|
.get('/api/admin/chat/messages')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.auth('admin', 'abc123');
|
.auth('admin', 'abc123');
|
||||||
|
|
||||||
const message = res.body.filter((obj) => {
|
const message = res.body.filter((obj) => {
|
||||||
return obj.body === establishedUserFailedChatMessage.body;
|
return obj.body === establishedUserFailedChatMessage.body;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(message.length).toBe(0);
|
expect(message.length).toBe(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can disable established chat user mode', async (done) => {
|
test('can disable established chat user mode', async (done) => {
|
||||||
await request
|
await request
|
||||||
.post('/api/admin/config/chat/establishedusermode')
|
.post('/api/admin/config/chat/establishedusermode')
|
||||||
.auth('admin', 'abc123')
|
.auth('admin', 'abc123')
|
||||||
.send({ value: false })
|
.send({ value: false })
|
||||||
.expect(200);
|
.expect(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -7,13 +7,13 @@ export const URL_CONFIG = `/api/config`;
|
|||||||
export const URL_VIEWER_PING = `/api/ping`;
|
export const URL_VIEWER_PING = `/api/ping`;
|
||||||
|
|
||||||
// inline moderation actions
|
// inline moderation actions
|
||||||
export const URL_HIDE_MESSAGE = `/api/chat/updatemessagevisibility`;
|
export const URL_HIDE_MESSAGE = `/api/chat/messagevisibility`;
|
||||||
export const URL_BAN_USER = `/api/chat/users/setenabled`;
|
export const URL_BAN_USER = `/api/chat/users/setenabled`;
|
||||||
|
|
||||||
// TODO: This directory is customizable in the config. So we should expose this via the config API.
|
// TODO: This directory is customizable in the config. So we should expose this via the config API.
|
||||||
export const URL_STREAM = `/hls/stream.m3u8`;
|
export const URL_STREAM = `/hls/stream.m3u8`;
|
||||||
export const URL_WEBSOCKET = `${
|
export const URL_WEBSOCKET = `${
|
||||||
location.protocol === 'https:' ? 'wss' : 'ws'
|
location.protocol === 'https:' ? 'wss' : 'ws'
|
||||||
}://${location.host}/ws`;
|
}://${location.host}/ws`;
|
||||||
export const URL_CHAT_REGISTRATION = `/api/chat/register`;
|
export const URL_CHAT_REGISTRATION = `/api/chat/register`;
|
||||||
export const URL_FOLLOWERS = `/api/followers`;
|
export const URL_FOLLOWERS = `/api/followers`;
|
||||||
@ -27,7 +27,7 @@ export const TIMER_STATUS_UPDATE = 5000; // ms
|
|||||||
export const TIMER_DISABLE_CHAT_AFTER_OFFLINE = 5 * 60 * 1000; // 5 mins
|
export const TIMER_DISABLE_CHAT_AFTER_OFFLINE = 5 * 60 * 1000; // 5 mins
|
||||||
export const TIMER_STREAM_DURATION_COUNTER = 1000;
|
export const TIMER_STREAM_DURATION_COUNTER = 1000;
|
||||||
export const TEMP_IMAGE =
|
export const TEMP_IMAGE =
|
||||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||||
|
|
||||||
export const OWNCAST_LOGO_LOCAL = '/img/logo.svg';
|
export const OWNCAST_LOGO_LOCAL = '/img/logo.svg';
|
||||||
|
|
||||||
@ -44,22 +44,22 @@ export const KEY_CUSTOM_USERNAME_SET = 'owncast_custom_username_set';
|
|||||||
export const KEY_CHAT_DISPLAYED = 'owncast_chat';
|
export const KEY_CHAT_DISPLAYED = 'owncast_chat';
|
||||||
export const KEY_CHAT_FIRST_MESSAGE_SENT = 'owncast_first_message_sent';
|
export const KEY_CHAT_FIRST_MESSAGE_SENT = 'owncast_first_message_sent';
|
||||||
export const CHAT_INITIAL_PLACEHOLDER_TEXT =
|
export const CHAT_INITIAL_PLACEHOLDER_TEXT =
|
||||||
'Type here to chat, no account necessary.';
|
'Type here to chat, no account necessary.';
|
||||||
export const CHAT_PLACEHOLDER_TEXT = 'Message';
|
export const CHAT_PLACEHOLDER_TEXT = 'Message';
|
||||||
export const CHAT_PLACEHOLDER_OFFLINE = 'Chat is offline.';
|
export const CHAT_PLACEHOLDER_OFFLINE = 'Chat is offline.';
|
||||||
export const CHAT_MAX_MESSAGE_LENGTH = 500;
|
export const CHAT_MAX_MESSAGE_LENGTH = 500;
|
||||||
export const EST_SOCKET_PAYLOAD_BUFFER = 512;
|
export const EST_SOCKET_PAYLOAD_BUFFER = 512;
|
||||||
export const CHAT_CHAR_COUNT_BUFFER = 20;
|
export const CHAT_CHAR_COUNT_BUFFER = 20;
|
||||||
export const CHAT_OK_KEYCODES = [
|
export const CHAT_OK_KEYCODES = [
|
||||||
'ArrowLeft',
|
'ArrowLeft',
|
||||||
'ArrowUp',
|
'ArrowUp',
|
||||||
'ArrowRight',
|
'ArrowRight',
|
||||||
'ArrowDown',
|
'ArrowDown',
|
||||||
'Shift',
|
'Shift',
|
||||||
'Meta',
|
'Meta',
|
||||||
'Alt',
|
'Alt',
|
||||||
'Delete',
|
'Delete',
|
||||||
'Backspace',
|
'Backspace',
|
||||||
];
|
];
|
||||||
export const CHAT_KEY_MODIFIERS = ['Control', 'Shift', 'Meta', 'Alt'];
|
export const CHAT_KEY_MODIFIERS = ['Control', 'Shift', 'Meta', 'Alt'];
|
||||||
export const MESSAGE_JUMPTOBOTTOM_BUFFER = 500;
|
export const MESSAGE_JUMPTOBOTTOM_BUFFER = 500;
|
||||||
@ -72,7 +72,7 @@ export const ORIENTATION_LANDSCAPE = 'landscape';
|
|||||||
|
|
||||||
// localstorage keys
|
// localstorage keys
|
||||||
export const HAS_DISPLAYED_NOTIFICATION_MODAL_KEY =
|
export const HAS_DISPLAYED_NOTIFICATION_MODAL_KEY =
|
||||||
'HAS_DISPLAYED_NOTIFICATION_MODAL';
|
'HAS_DISPLAYED_NOTIFICATION_MODAL';
|
||||||
export const USER_VISIT_COUNT_KEY = 'USER_VISIT_COUNT';
|
export const USER_VISIT_COUNT_KEY = 'USER_VISIT_COUNT';
|
||||||
export const USER_DISMISSED_ANNOYING_NOTIFICATION_POPUP_KEY =
|
export const USER_DISMISSED_ANNOYING_NOTIFICATION_POPUP_KEY =
|
||||||
'USER_DISMISSED_ANNOYING_NOTIFICATION_POPUP_KEY';
|
'USER_DISMISSED_ANNOYING_NOTIFICATION_POPUP_KEY';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user