Standardize endpoint name and fix doc. Closes #1966
This commit is contained in:
parent
6ff8c89246
commit
3741196de6
@ -686,7 +686,7 @@ paths:
|
||||
type: string
|
||||
example: https://fediverse.biz/authorize_interaction?uri=https://my.owncast.server/federation/user/streamer
|
||||
|
||||
/api/chat/updatemessagevisibility:
|
||||
/api/chat/messagevisibility:
|
||||
post:
|
||||
summary: Update the visibility of chat messages.
|
||||
description: Pass an array of IDs you want to change the chat visibility of.
|
||||
@ -951,7 +951,7 @@ paths:
|
||||
type: string
|
||||
format: date-time
|
||||
|
||||
/api/admin/chat/updatemessagevisibility:
|
||||
/api/admin/chat/messagevisibility:
|
||||
post:
|
||||
summary: Update the visibility of chat messages.
|
||||
description: Pass an array of IDs you want to change the chat visibility of.
|
||||
@ -1984,7 +1984,7 @@ paths:
|
||||
type: string
|
||||
format: date-time
|
||||
|
||||
/api/integrations/chat/updatemessagevisibility:
|
||||
/api/integrations/chat/messagevisibility:
|
||||
post:
|
||||
summary: Update the visibility of chat messages.
|
||||
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))
|
||||
|
||||
// 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
|
||||
http.HandleFunc("/api/admin/chat/users/setenabled", middleware.RequireAdminAuth(admin.UpdateUserEnabled))
|
||||
@ -310,7 +310,7 @@ func Start() error {
|
||||
// Inline chat moderation actions
|
||||
|
||||
// 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
|
||||
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 testVisibilityMessage = {
|
||||
body: 'message ' + Math.floor(Math.random() * 100),
|
||||
type: 'CHAT',
|
||||
body: 'message ' + Math.floor(Math.random() * 100),
|
||||
type: 'CHAT',
|
||||
};
|
||||
|
||||
var messageId;
|
||||
|
||||
const establishedUserFailedChatMessage = {
|
||||
body: 'this message should fail to send ' + Math.floor(Math.random() * 100),
|
||||
type: 'CHAT',
|
||||
body: 'this message should fail to send ' + Math.floor(Math.random() * 100),
|
||||
type: 'CHAT',
|
||||
};
|
||||
|
||||
test('can send a chat message', async (done) => {
|
||||
const registration = await registerChat();
|
||||
const accessToken = registration.accessToken;
|
||||
const registration = await registerChat();
|
||||
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) => {
|
||||
const registration = await registerChat();
|
||||
const accessToken = registration.accessToken;
|
||||
const ws = new WebSocket(
|
||||
`ws://localhost:8080/ws?accessToken=${accessToken}`,
|
||||
{
|
||||
origin: 'http://localhost:8080',
|
||||
}
|
||||
);
|
||||
const registration = await registerChat();
|
||||
const accessToken = registration.accessToken;
|
||||
const ws = new WebSocket(
|
||||
`ws://localhost:8080/ws?accessToken=${accessToken}`,
|
||||
{
|
||||
origin: 'http://localhost:8080',
|
||||
}
|
||||
);
|
||||
|
||||
// Verify the visibility change comes through the websocket
|
||||
ws.on('message', async function incoming(message) {
|
||||
const messages = message.split('\n');
|
||||
messages.forEach(async function (message) {
|
||||
const event = JSON.parse(message);
|
||||
// Verify the visibility change comes through the websocket
|
||||
ws.on('message', async function incoming(message) {
|
||||
const messages = message.split('\n');
|
||||
messages.forEach(async function (message) {
|
||||
const event = JSON.parse(message);
|
||||
|
||||
if (event.type === 'VISIBILITY-UPDATE') {
|
||||
ws.close();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
if (event.type === 'VISIBILITY-UPDATE') {
|
||||
ws.close();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const res = await request
|
||||
.get('/api/admin/chat/messages')
|
||||
.auth('admin', 'abc123')
|
||||
.expect(200);
|
||||
const res = await request
|
||||
.get('/api/admin/chat/messages')
|
||||
.auth('admin', 'abc123')
|
||||
.expect(200);
|
||||
|
||||
const message = res.body[0];
|
||||
messageId = message.id;
|
||||
await request
|
||||
.post('/api/admin/chat/updatemessagevisibility')
|
||||
.auth('admin', 'abc123')
|
||||
.send({ idArray: [messageId], visible: false })
|
||||
.expect(200);
|
||||
const message = res.body[0];
|
||||
messageId = message.id;
|
||||
await request
|
||||
.post('/api/admin/chat/messagevisibility')
|
||||
.auth('admin', 'abc123')
|
||||
.send({ idArray: [messageId], visible: false })
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
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
|
||||
.get('/api/admin/chat/messages')
|
||||
.expect(200)
|
||||
.auth('admin', 'abc123');
|
||||
const res = await request
|
||||
.get('/api/admin/chat/messages')
|
||||
.expect(200)
|
||||
.auth('admin', 'abc123');
|
||||
|
||||
const message = res.body.filter((obj) => {
|
||||
return obj.id === messageId;
|
||||
});
|
||||
expect(message.length).toBe(1);
|
||||
// expect(message[0].hiddenAt).toBeTruthy();
|
||||
done();
|
||||
const message = res.body.filter((obj) => {
|
||||
return obj.id === messageId;
|
||||
});
|
||||
expect(message.length).toBe(1);
|
||||
// expect(message[0].hiddenAt).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
|
||||
test('can enable established chat user mode', async (done) => {
|
||||
await request
|
||||
.post('/api/admin/config/chat/establishedusermode')
|
||||
.auth('admin', 'abc123')
|
||||
.send({ value: true })
|
||||
.expect(200);
|
||||
done();
|
||||
await request
|
||||
.post('/api/admin/config/chat/establishedusermode')
|
||||
.auth('admin', 'abc123')
|
||||
.send({ value: true })
|
||||
.expect(200);
|
||||
done();
|
||||
});
|
||||
|
||||
test('can send a message after established user mode is enabled', async (done) => {
|
||||
const registration = await registerChat();
|
||||
const accessToken = registration.accessToken;
|
||||
const registration = await registerChat();
|
||||
const accessToken = registration.accessToken;
|
||||
|
||||
sendChatMessage(establishedUserFailedChatMessage, accessToken, done);
|
||||
sendChatMessage(establishedUserFailedChatMessage, accessToken, done);
|
||||
});
|
||||
|
||||
test('verify rejected message is not in the chat feed', async (done) => {
|
||||
const res = await request
|
||||
.get('/api/admin/chat/messages')
|
||||
.expect(200)
|
||||
.auth('admin', 'abc123');
|
||||
const res = await request
|
||||
.get('/api/admin/chat/messages')
|
||||
.expect(200)
|
||||
.auth('admin', 'abc123');
|
||||
|
||||
const message = res.body.filter((obj) => {
|
||||
return obj.body === establishedUserFailedChatMessage.body;
|
||||
});
|
||||
const message = res.body.filter((obj) => {
|
||||
return obj.body === establishedUserFailedChatMessage.body;
|
||||
});
|
||||
|
||||
expect(message.length).toBe(0);
|
||||
done();
|
||||
expect(message.length).toBe(0);
|
||||
done();
|
||||
});
|
||||
|
||||
test('can disable established chat user mode', async (done) => {
|
||||
await request
|
||||
.post('/api/admin/config/chat/establishedusermode')
|
||||
.auth('admin', 'abc123')
|
||||
.send({ value: false })
|
||||
.expect(200);
|
||||
done();
|
||||
await request
|
||||
.post('/api/admin/config/chat/establishedusermode')
|
||||
.auth('admin', 'abc123')
|
||||
.send({ value: false })
|
||||
.expect(200);
|
||||
done();
|
||||
});
|
||||
|
@ -7,13 +7,13 @@ export const URL_CONFIG = `/api/config`;
|
||||
export const URL_VIEWER_PING = `/api/ping`;
|
||||
|
||||
// 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`;
|
||||
|
||||
// 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_WEBSOCKET = `${
|
||||
location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
}://${location.host}/ws`;
|
||||
export const URL_CHAT_REGISTRATION = `/api/chat/register`;
|
||||
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_STREAM_DURATION_COUNTER = 1000;
|
||||
export const TEMP_IMAGE =
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
|
||||
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_FIRST_MESSAGE_SENT = 'owncast_first_message_sent';
|
||||
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_OFFLINE = 'Chat is offline.';
|
||||
export const CHAT_MAX_MESSAGE_LENGTH = 500;
|
||||
export const EST_SOCKET_PAYLOAD_BUFFER = 512;
|
||||
export const CHAT_CHAR_COUNT_BUFFER = 20;
|
||||
export const CHAT_OK_KEYCODES = [
|
||||
'ArrowLeft',
|
||||
'ArrowUp',
|
||||
'ArrowRight',
|
||||
'ArrowDown',
|
||||
'Shift',
|
||||
'Meta',
|
||||
'Alt',
|
||||
'Delete',
|
||||
'Backspace',
|
||||
'ArrowLeft',
|
||||
'ArrowUp',
|
||||
'ArrowRight',
|
||||
'ArrowDown',
|
||||
'Shift',
|
||||
'Meta',
|
||||
'Alt',
|
||||
'Delete',
|
||||
'Backspace',
|
||||
];
|
||||
export const CHAT_KEY_MODIFIERS = ['Control', 'Shift', 'Meta', 'Alt'];
|
||||
export const MESSAGE_JUMPTOBOTTOM_BUFFER = 500;
|
||||
@ -72,7 +72,7 @@ export const ORIENTATION_LANDSCAPE = 'landscape';
|
||||
|
||||
// localstorage keys
|
||||
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_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