Finished up work on advanced formatted private messaging.
This commit is contained in:
parent
faf72fd7a5
commit
2feea72694
11 changed files with 164 additions and 94 deletions
|
|
@ -30,13 +30,19 @@ class pmHandler{
|
|||
/**
|
||||
* Instantiates object containing global server-side private message relay logic
|
||||
* @param {Socket.io} io - Socket.io server instanced passed down from server.js
|
||||
* @param {channelManager} chanServer - Sister channel management server object
|
||||
*/
|
||||
constructor(io){
|
||||
constructor(io, chanServer){
|
||||
/**
|
||||
* Socket.io server instance passed down from server.js
|
||||
*/
|
||||
this.io = io;
|
||||
|
||||
/**
|
||||
* Sister channel management server object
|
||||
*/
|
||||
this.chanServer = chanServer;
|
||||
|
||||
/**
|
||||
* Socket.io server namespace for handling messaging
|
||||
*/
|
||||
|
|
@ -107,14 +113,28 @@ class pmHandler{
|
|||
//preprocess message
|
||||
const preprocessedMessage = await this.chatPreprocessor.preprocess(socket, data);
|
||||
|
||||
//Create message object and relay it off to the recipients
|
||||
this.relayPMObj(new message(
|
||||
socket.user.user,
|
||||
recipients,
|
||||
preprocessedMessage.message,
|
||||
preprocessedMessage.chatType,
|
||||
preprocessedMessage.links
|
||||
));
|
||||
//If the send flag wasnt thrown false
|
||||
if(preprocessedMessage != false){
|
||||
//Pull an active user profile from the first channel that gives it in the chan server
|
||||
const senderProfile = this.chanServer.activeUsers.get(socket.user.user);
|
||||
|
||||
//If user isn't actively connected to a channel
|
||||
if(senderProfile == null || senderProfile.length == 0){
|
||||
//They don't get to send shit lol
|
||||
return;
|
||||
}
|
||||
|
||||
//Create message object and relay it off to the recipients
|
||||
this.relayPMObj(new message(
|
||||
socket.user.user,
|
||||
recipients,
|
||||
senderProfile[0].flair,
|
||||
senderProfile[0].highLevel,
|
||||
preprocessedMessage.message,
|
||||
preprocessedMessage.chatType,
|
||||
preprocessedMessage.links
|
||||
));
|
||||
}
|
||||
|
||||
//If something fucked up
|
||||
}catch(err){
|
||||
|
|
@ -131,7 +151,7 @@ class pmHandler{
|
|||
}
|
||||
|
||||
//Acknowledge the sent message
|
||||
this.namespace.to(msg.sender).emit("sent", msg);
|
||||
this.namespace.to(msg.user).emit("sent", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue