wip
This commit is contained in:
@@ -83,8 +83,8 @@ const mainChannel = stream.useChannel('main');
|
||||
``` ts
|
||||
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
|
||||
|
||||
const messagingChannel = stream.useChannel('messaging', {
|
||||
otherparty: 'xxxxxxxxxx',
|
||||
const chatChannel = stream.useChannel('chat', {
|
||||
other: 'xxxxxxxxxx',
|
||||
});
|
||||
```
|
||||
|
||||
@@ -115,11 +115,11 @@ mainChannel.on('notification', notification => {
|
||||
|
||||
``` ts
|
||||
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
|
||||
const messagingChannel = stream.useChannel('messaging', {
|
||||
otherparty: 'xxxxxxxxxx',
|
||||
const chatChannel = stream.useChannel('chat', {
|
||||
other: 'xxxxxxxxxx',
|
||||
});
|
||||
|
||||
messagingChannel.send('read', {
|
||||
chatChannel.send('read', {
|
||||
id: 'xxxxxxxxxx'
|
||||
});
|
||||
```
|
||||
|
@@ -37,8 +37,8 @@ export const permissions = [
|
||||
'write:favorites',
|
||||
'read:following',
|
||||
'write:following',
|
||||
'read:messaging',
|
||||
'write:messaging',
|
||||
'read:messaging', // deprecated
|
||||
'write:messaging', // deprecated
|
||||
'read:mutes',
|
||||
'write:mutes',
|
||||
'write:notes',
|
||||
@@ -110,6 +110,8 @@ export const permissions = [
|
||||
'read:clip-favorite',
|
||||
'read:federation',
|
||||
'write:report-abuse',
|
||||
'write:chat',
|
||||
'read:chat',
|
||||
] as const;
|
||||
|
||||
export const moderationLogTypes = [
|
||||
|
@@ -42,26 +42,26 @@ describe('Streaming', () => {
|
||||
test('useChannel with parameters', async () => {
|
||||
const server = new WS('wss://misskey.test/streaming');
|
||||
const stream = new Stream('https://misskey.test', { token: 'TOKEN' });
|
||||
const messagingChannelReceived: any[] = [];
|
||||
const messaging = stream.useChannel('messaging', { otherparty: 'aaa' });
|
||||
messaging.on('message', payload => {
|
||||
messagingChannelReceived.push(payload);
|
||||
const chatChannelReceived: any[] = [];
|
||||
const chat = stream.useChannel('chat', { other: 'aaa' });
|
||||
chat.on('message', payload => {
|
||||
chatChannelReceived.push(payload);
|
||||
});
|
||||
|
||||
const ws = await server.connected;
|
||||
expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN');
|
||||
|
||||
const msg = JSON.parse(await server.nextMessage as string);
|
||||
const messagingChannelId = msg.body.id;
|
||||
const chatChannelId = msg.body.id;
|
||||
expect(msg.type).toEqual('connect');
|
||||
expect(msg.body.channel).toEqual('messaging');
|
||||
expect(msg.body.params).toEqual({ otherparty: 'aaa' });
|
||||
expect(messagingChannelId != null).toEqual(true);
|
||||
expect(msg.body.channel).toEqual('chat');
|
||||
expect(msg.body.params).toEqual({ other: 'aaa' });
|
||||
expect(chatChannelId != null).toEqual(true);
|
||||
|
||||
server.send(JSON.stringify({
|
||||
type: 'channel',
|
||||
body: {
|
||||
id: messagingChannelId,
|
||||
id: chatChannelId,
|
||||
type: 'message',
|
||||
body: {
|
||||
id: 'foo'
|
||||
@@ -69,7 +69,7 @@ describe('Streaming', () => {
|
||||
}
|
||||
}));
|
||||
|
||||
expect(messagingChannelReceived[0]).toEqual({
|
||||
expect(chatChannelReceived[0]).toEqual({
|
||||
id: 'foo'
|
||||
});
|
||||
|
||||
@@ -81,20 +81,20 @@ describe('Streaming', () => {
|
||||
const server = new WS('wss://misskey.test/streaming');
|
||||
const stream = new Stream('https://misskey.test', { token: 'TOKEN' });
|
||||
|
||||
stream.useChannel('messaging', { otherparty: 'aaa' });
|
||||
stream.useChannel('messaging', { otherparty: 'bbb' });
|
||||
stream.useChannel('chat', { other: 'aaa' });
|
||||
stream.useChannel('chat', { other: 'bbb' });
|
||||
|
||||
const ws = await server.connected;
|
||||
expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN');
|
||||
|
||||
const msg = JSON.parse(await server.nextMessage as string);
|
||||
const messagingChannelId = msg.body.id;
|
||||
const chatChannelId = msg.body.id;
|
||||
const msg2 = JSON.parse(await server.nextMessage as string);
|
||||
const messagingChannelId2 = msg2.body.id;
|
||||
const chatChannelId2 = msg2.body.id;
|
||||
|
||||
expect(messagingChannelId != null).toEqual(true);
|
||||
expect(messagingChannelId2 != null).toEqual(true);
|
||||
expect(messagingChannelId).not.toEqual(messagingChannelId2);
|
||||
expect(chatChannelId != null).toEqual(true);
|
||||
expect(chatChannelId2 != null).toEqual(true);
|
||||
expect(chatChannelId).not.toEqual(chatChannelId2);
|
||||
|
||||
stream.close();
|
||||
server.close();
|
||||
@@ -104,8 +104,8 @@ describe('Streaming', () => {
|
||||
const server = new WS('wss://misskey.test/streaming');
|
||||
const stream = new Stream('https://misskey.test', { token: 'TOKEN' });
|
||||
|
||||
const messaging = stream.useChannel('messaging', { otherparty: 'aaa' });
|
||||
messaging.send('read', { id: 'aaa' });
|
||||
const chat = stream.useChannel('chat', { other: 'aaa' });
|
||||
chat.send('read', { id: 'aaa' });
|
||||
|
||||
const ws = await server.connected;
|
||||
expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN');
|
||||
|
Reference in New Issue
Block a user