Bug 1172355 - Add system messages when someone joins or leaves an XMPP MUC. r=aleth
This commit is contained in:
Родитель
53846ff156
Коммит
b8b60b0cad
|
@ -108,11 +108,25 @@ chatRoomField.password=_Password
|
||||||
conversation.muc.invitationWithReason=%1$S has invited you to join %2$S: %3$S
|
conversation.muc.invitationWithReason=%1$S has invited you to join %2$S: %3$S
|
||||||
conversation.muc.invitationWithoutReason=%1$S has invited you to join %2$S
|
conversation.muc.invitationWithoutReason=%1$S has invited you to join %2$S
|
||||||
|
|
||||||
|
# LOCALIZATION NOTE (conversation.muc.join):
|
||||||
|
# This is displayed as a system message when a participant joins room.
|
||||||
|
# %S is the nick of the participant.
|
||||||
|
conversation.message.join=%S entered the room.
|
||||||
|
|
||||||
|
# LOCALIZATION NOTE (conversation.muc.rejoined):
|
||||||
|
# This is displayed as a system message when a participant rejoins room after
|
||||||
|
# parting it.
|
||||||
|
conversation.message.rejoined=You have rejoined the room.
|
||||||
|
|
||||||
# LOCALIZATION NOTE (conversation.message.parted.*):
|
# LOCALIZATION NOTE (conversation.message.parted.*):
|
||||||
# These are displayed as a system message when a participant parts a room.
|
# These are displayed as a system message when a participant parts a room.
|
||||||
# %S is the part message supplied by the user.
|
# %S is the part message supplied by the user.
|
||||||
conversation.message.parted.you=You have left the room.
|
conversation.message.parted.you=You have left the room.
|
||||||
conversation.message.parted.you.reason=You have left the room: %S
|
conversation.message.parted.you.reason=You have left the room: %S
|
||||||
|
# %1$S is the participant that is leaving.
|
||||||
|
# %2$S is the part message supplied by the participant.
|
||||||
|
conversation.message.parted=%1$S has left the room.
|
||||||
|
conversation.message.parted.reason=%1$S has left the room: %2$S
|
||||||
|
|
||||||
# LOCALIZATION NOTE (conversation.message.banned.*):
|
# LOCALIZATION NOTE (conversation.message.banned.*):
|
||||||
# These are displayed as a system message when a participant is banned from
|
# These are displayed as a system message when a participant is banned from
|
||||||
|
|
|
@ -165,6 +165,9 @@ const XMPPMUCConversationPrototype = {
|
||||||
|
|
||||||
_targetResource: "",
|
_targetResource: "",
|
||||||
|
|
||||||
|
// True while we are rejoining a room previously parted by the user.
|
||||||
|
_rejoined: false,
|
||||||
|
|
||||||
get topic() this._topic,
|
get topic() this._topic,
|
||||||
set topic(aTopic) {
|
set topic(aTopic) {
|
||||||
let notAuthorized = (aError) => {
|
let notAuthorized = (aError) => {
|
||||||
|
@ -284,17 +287,7 @@ const XMPPMUCConversationPrototype = {
|
||||||
this.left = true;
|
this.left = true;
|
||||||
|
|
||||||
let message;
|
let message;
|
||||||
if (codes.indexOf("110") != -1) {
|
if (codes.indexOf("301") != -1) {
|
||||||
// XEP-0045 7.14: Self-presence.
|
|
||||||
// Received when the user parts a room.
|
|
||||||
message = "conversation.message.parted";
|
|
||||||
|
|
||||||
// The reason is in a status element in this case.
|
|
||||||
reasonNode = aStanza.getElement(["status"]);
|
|
||||||
reason = reasonNode ? reasonNode.innerText : "";
|
|
||||||
isReason = reason ? ".reason" : "";
|
|
||||||
}
|
|
||||||
else if (codes.indexOf("301") != -1) {
|
|
||||||
// XEP-0045 (9.1): Banning a User.
|
// XEP-0045 (9.1): Banning a User.
|
||||||
message = "conversation.message.banned";
|
message = "conversation.message.banned";
|
||||||
}
|
}
|
||||||
|
@ -316,6 +309,16 @@ const XMPPMUCConversationPrototype = {
|
||||||
// The reason here just duplicates what's in the system message.
|
// The reason here just duplicates what's in the system message.
|
||||||
reason = isReason = "";
|
reason = isReason = "";
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// XEP-0045 (7.14): Received when the user parts a room.
|
||||||
|
message = "conversation.message.parted";
|
||||||
|
|
||||||
|
// The reason is in a status element in this case.
|
||||||
|
reasonNode = aStanza.getElement(["status"]);
|
||||||
|
reason = reasonNode ? reasonNode.innerText : "";
|
||||||
|
isReason = reason ? ".reason" : "";
|
||||||
|
}
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
let messageID = message + isYou + isActor + isReason;
|
let messageID = message + isYou + isActor + isReason;
|
||||||
let params = [actorNick, affectedNick, reason].filter(s => s);
|
let params = [actorNick, affectedNick, reason].filter(s => s);
|
||||||
|
@ -360,6 +363,15 @@ const XMPPMUCConversationPrototype = {
|
||||||
this._participants.set(nick, participant);
|
this._participants.set(nick, participant);
|
||||||
this.notifyObservers(new nsSimpleEnumerator([participant]),
|
this.notifyObservers(new nsSimpleEnumerator([participant]),
|
||||||
"chat-buddy-add");
|
"chat-buddy-add");
|
||||||
|
if (this.nick != nick && !this.joining) {
|
||||||
|
this.writeMessage(this.name, _("conversation.message.join", nick),
|
||||||
|
{system: true});
|
||||||
|
}
|
||||||
|
else if (this.nick == nick && this._rejoined) {
|
||||||
|
this.writeMessage(this.name, _("conversation.message.rejoined"),
|
||||||
|
{system: true});
|
||||||
|
this._rejoined = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._participants.get(nick).onPresenceStanza(aStanza);
|
this._participants.get(nick).onPresenceStanza(aStanza);
|
||||||
|
@ -1020,6 +1032,10 @@ const XMPPAccountPrototype = {
|
||||||
if (muc) {
|
if (muc) {
|
||||||
if (!muc.left)
|
if (!muc.left)
|
||||||
return muc; // We are already in this conversation.
|
return muc; // We are already in this conversation.
|
||||||
|
else if (!muc.chatRoomFields) {
|
||||||
|
// We are rejoining a room that was parted by the user.
|
||||||
|
muc._rejoined = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
muc = new this._MUCConversationConstructor(this, jid, nick);
|
muc = new this._MUCConversationConstructor(this, jid, nick);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче