Added proper log message for moved clients which enter the view

This commit is contained in:
WolverinDEV 2019-10-24 18:24:28 +02:00
parent 66326b2cc9
commit 89d2f8db88
2 changed files with 23 additions and 18 deletions

View file

@ -498,8 +498,9 @@ namespace connection {
this.connection.client.handleDisconnect(DisconnectReason.SERVER_CLOSED, entry);
} else if(reason_id == ViewReasonId.VREASON_SERVER_STOPPED) {
this.connection.client.handleDisconnect(DisconnectReason.SERVER_CLOSED, entry);
} else
} else {
this.connection.client.handleDisconnect(DisconnectReason.UNKNOWN, entry);
}
this.connection_handler.side_bar.info_frame().update_channel_talk();
return;
}
@ -510,6 +511,7 @@ namespace connection {
let channel_from = tree.findChannel(entry["cfid"]);
let channel_to = tree.findChannel(entry["ctid"]);
const is_own_channel = channel_from == own_channel;
this.connection_handler.log.log(log.server.Type.CLIENT_VIEW_LEAVE, {
channel_from: channel_from ? channel_from.log_data() : undefined,
channel_to: channel_to ? channel_to.log_data() : undefined,
@ -518,28 +520,27 @@ namespace connection {
message: entry["reasonmsg"],
reason: parseInt(entry["reasonid"]),
ban_time: parseInt(entry["bantime"]),
own_channel: channel_from == own_channel
own_channel: is_own_channel
});
if(reason_id == ViewReasonId.VREASON_USER_ACTION) {
if(channel_from == own_channel)
if(is_own_channel) {
if(reason_id == ViewReasonId.VREASON_USER_ACTION) {
this.connection_handler.sound.play(Sound.USER_LEFT);
} else if(reason_id == ViewReasonId.VREASON_SERVER_LEFT) {
if(channel_from == own_channel)
} else if(reason_id == ViewReasonId.VREASON_SERVER_LEFT) {
this.connection_handler.sound.play(Sound.USER_LEFT_DISCONNECT);
} else if(reason_id == ViewReasonId.VREASON_SERVER_KICK) {
if(channel_from == own_channel)
} else if(reason_id == ViewReasonId.VREASON_SERVER_KICK) {
this.connection_handler.sound.play(Sound.USER_LEFT_KICKED_SERVER);
} else if(reason_id == ViewReasonId.VREASON_CHANNEL_KICK) {
if(channel_from == own_channel)
} else if(reason_id == ViewReasonId.VREASON_CHANNEL_KICK) {
this.connection_handler.sound.play(Sound.USER_LEFT_KICKED_CHANNEL);
} else if(reason_id == ViewReasonId.VREASON_BAN) {
if(channel_from == own_channel)
} else if(reason_id == ViewReasonId.VREASON_BAN) {
this.connection_handler.sound.play(Sound.USER_LEFT_BANNED);
} else if(reason_id == ViewReasonId.VREASON_TIMEOUT) {
if(channel_from == own_channel)
} else if(reason_id == ViewReasonId.VREASON_TIMEOUT) {
this.connection_handler.sound.play(Sound.USER_LEFT_TIMEOUT);
} else {
log.error(LogCategory.NETWORKING, tr("Unknown client left reason!"));
} else if(reason_id == ViewReasonId.VREASON_MOVED) {
this.connection_handler.sound.play(Sound.USER_LEFT_MOVED);
} else {
log.error(LogCategory.NETWORKING, tr("Unknown client left reason %d!"), reason_id);
}
}
if(!channel_to) {
@ -553,8 +554,9 @@ namespace connection {
create: false,
attach: false
});
if(conversation)
if(conversation) {
conversation.set_state(chat.PrivateConversationState.DISCONNECTED);
}
}
}

View file

@ -505,8 +505,11 @@ namespace log {
);
} else if(data.reason == ViewReasonId.VREASON_TIMEOUT) {
return MessageHelper.formatMessage(tr("{0} timed out{1}"), client_tag(data.client), data.message ? (" (" + data.message + ")") : "");
} else if(data.reason == ViewReasonId.VREASON_MOVED) {
return MessageHelper.formatMessage(data.own_channel ? tr("{0} disappeared from your channel {1} to {2}, moved by {3}") : tr("{0} disappeared from {1} to {2}, moved by {3}"), client_tag(data.client), channel_tag(data.channel_from), channel_tag(data.channel_to), client_tag(data.invoker));
}
return [$.spawn("div").addClass("log-error").text("Invalid view leave reason id (" + data.message + ")")];
return [$.spawn("div").addClass("log-error").text("Invalid view leave reason id (" + data.reason + ")")];
};
MessageBuilders["server_welcome_message"] = (data: event.WelcomeMessage, options) => {