Store file upload history on server

master
Torjus 2018-07-31 09:56:29 +02:00
parent 8b6ebe39b2
commit 35b3da155d
4 changed files with 60 additions and 1 deletions

View File

@ -238,6 +238,22 @@ export default class RoomClient
});
}
getFileHistory()
{
logger.debug('getFileHistory()');
return this._protoo.send('file-history', {})
.catch((error) =>
{
logger.error('getFileHistory() | failed: %o', error);
this._dispatch(requestActions.notify({
type: 'error',
text: 'Could not get file history'
}));
})
}
muteMic()
{
logger.debug('muteMic()');
@ -1177,6 +1193,22 @@ export default class RoomClient
break;
}
case 'file-history-receive':
{
accept();
const files = request.data.fileHistory;
if (files.length > 0)
{
logger.debug('Got files history');
this._dispatch(stateActions.addFileHistory(files));
}
break;
}
default:
{
logger.error('unknown protoo method "%s"', request.method);
@ -1314,7 +1346,8 @@ export default class RoomClient
this._dispatch(stateActions.removeAllNotifications());
this.getChatHistory();
this.getFileHistory();
this._dispatch(requestActions.notify(
{
text : 'You are in the room',

View File

@ -8,6 +8,9 @@ const sharing = (state = [], action) =>
case 'ADD_FILE':
return [ ...state, action.payload ];
case 'ADD_FILE_HISTORY':
return [ ...action.payload.fileHistory, ...state ];
default:
return state;
}

View File

@ -449,6 +449,14 @@ export const addFile = (payload) =>
};
};
export const addFileHistory = (fileHistory) =>
{
return {
type: 'ADD_FILE_HISTORY',
payload: { fileHistory }
};
};
export const setPicture = (picture) =>
({
type : 'SET_PICTURE',

View File

@ -28,6 +28,8 @@ class Room extends EventEmitter
this._chatHistory = [];
this._fileHistory = [];
try
{
// Protoo Room instance.
@ -278,6 +280,8 @@ class Room extends EventEmitter
const { file } = request.data;
this._fileHistory.push(file);
this._protooRoom.spread('file-receive', {
file
}, [ protooPeer ]);
@ -285,6 +289,17 @@ class Room extends EventEmitter
break;
}
case 'file-history':
{
accept();
protooPeer.send('file-history-receive', {
fileHistory: this._fileHistory
});
break;
}
case 'raisehand-message':
{
accept();