Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
7c1a9242
Commit
7c1a9242
authored
May 11, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add logic to parse error messages when trying to enter a room
parent
c392a4e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
178 additions
and
7 deletions
+178
-7
converse.js
converse.js
+26
-6
spec/MainSpec.js
spec/MainSpec.js
+151
-0
tests_main.js
tests_main.js
+1
-1
No files found.
converse.js
View file @
7c1a9242
...
...
@@ -1092,9 +1092,32 @@
}
}
}
else
{
var
error
=
$presence
.
find
(
'
error
'
);
if
(
$
(
error
).
attr
(
'
type
'
)
==
'
auth
'
)
{
this
.
$el
.
find
(
'
.chat-content
'
).
append
(
'
Sorry, this chatroom is restricted
'
);
var
$error
=
$presence
.
find
(
'
error
'
),
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
if
(
$error
.
attr
(
'
type
'
)
==
'
auth
'
)
{
if
(
$error
.
find
(
'
not-authorized
'
).
length
)
{
$chat_content
.
append
(
'
This chatroom requires a password
'
);
}
else
if
(
$error
.
find
(
'
registration-required
'
).
length
)
{
$chat_content
.
append
(
'
You are not on the member list of this room
'
);
}
else
if
(
$error
.
find
(
'
forbidden
'
).
length
)
{
$chat_content
.
append
(
'
You have been banned from this room
'
);
}
}
else
if
(
$error
.
attr
(
'
type
'
)
==
'
modify
'
)
{
if
(
$error
.
find
(
'
jid-malformed
'
).
length
)
{
$chat_content
.
append
(
'
No nickname was specified
'
);
}
}
else
if
(
$error
.
attr
(
'
type
'
)
==
'
cancel
'
)
{
if
(
$error
.
find
(
'
not-allowed
'
).
length
)
{
$chat_content
.
append
(
'
You are not allowed to create new rooms
'
);
}
else
if
(
$error
.
find
(
'
not-acceptable
'
).
length
)
{
$chat_content
.
append
(
"
Your nickname doesn't conform to the room's policies
"
);
}
else
if
(
$error
.
find
(
'
conflict
'
).
length
)
{
$chat_content
.
append
(
"
Your nickname is already taken
"
);
}
else
if
(
$error
.
find
(
'
item-not-found
'
).
length
)
{
$chat_content
.
append
(
"
This room does not (yet) exist
"
);
}
else
if
(
$error
.
find
(
'
service-unavailable
'
).
length
)
{
$chat_content
.
append
(
"
This room has reached it's maximum number of occupants
"
);
}
}
}
return
true
;
...
...
@@ -1419,7 +1442,6 @@
this
.
$el
.
addClass
(
'
current-xmpp-contact
'
);
this
.
$el
.
html
(
this
.
template
(
item
.
toJSON
()));
}
return
this
;
},
...
...
@@ -1877,7 +1899,6 @@
converse
.
connection
.
send
(
$pres
().
c
(
'
show
'
).
t
(
this
.
get
(
'
status
'
)).
up
().
c
(
'
status
'
).
t
(
status_message
));
this
.
save
({
'
status_message
'
:
status_message
});
}
});
converse
.
XMPPStatusView
=
Backbone
.
View
.
extend
({
...
...
@@ -1909,7 +1930,6 @@
'
<a class="change-xmpp-status-message" href="#" Title="Click here to write a custom status message"></a>
'
+
'
</div>
'
),
renderStatusChangeForm
:
function
(
ev
)
{
ev
.
preventDefault
();
var
status_message
=
this
.
model
.
get
(
'
status
'
)
||
'
offline
'
;
...
...
spec/MainSpec.js
View file @
7c1a9242
...
...
@@ -713,5 +713,156 @@
expect
(
converse
.
connection
.
muc
.
leave
).
toHaveBeenCalled
();
},
converse
));
},
converse
));
describe
(
"
When attempting to enter a chatroom
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
var
roomspanel
=
this
.
chatboxesview
.
views
.
controlbox
.
roomspanel
;
var
$input
=
roomspanel
.
$el
.
find
(
'
input.new-chatroom-name
'
);
var
$server
=
roomspanel
.
$el
.
find
(
'
input.new-chatroom-server
'
);
$input
.
val
(
'
problematic
'
);
$server
.
val
(
'
muc.localhost
'
);
roomspanel
.
$el
.
find
(
'
form
'
).
submit
();
},
converse
));
afterEach
(
$
.
proxy
(
function
()
{
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
closeChat
();
},
converse
));
it
(
"
will show an error message if the room requires a password
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
auth
'
})
.
c
(
'
not-authorized
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
'
This chatroom requires a password
'
);
},
converse
));
it
(
"
will show an error message if the room is members-only and the user not included
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
auth
'
})
.
c
(
'
registration-required
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
'
You are not on the member list of this room
'
);
},
converse
));
it
(
"
will show an error message if the user has been banned
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
auth
'
})
.
c
(
'
forbidden
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
'
You have been banned from this room
'
);
},
converse
));
it
(
"
will show an error message if no nickname was specified for the user
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
modify
'
})
.
c
(
'
jid-malformed
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
'
No nickname was specified
'
);
},
converse
));
it
(
"
will show an error message if the user is not allowed to have created the room
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
cancel
'
})
.
c
(
'
not-allowed
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
'
You are not allowed to create new rooms
'
);
},
converse
));
it
(
"
will show an error message if the user's nickname doesn't conform to room policy
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
cancel
'
})
.
c
(
'
not-acceptable
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
"
Your nickname doesn't conform to the room's policies
"
);
},
converse
));
it
(
"
will show an error message if the user's nickname is already taken
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
"
Your nickname is already taken
"
);
},
converse
));
it
(
"
will show an error message if the room doesn't yet exist
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
cancel
'
})
.
c
(
'
item-not-found
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
"
This room does not (yet) exist
"
);
},
converse
));
it
(
"
will show an error message if the room has reached it's maximum number of occupants
"
,
$
.
proxy
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
coven@chat.shakespeare.lit/thirdwitch
'
,
id
:
'
n13mt3l
'
,
to
:
'
hag66@shakespeare.lit/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
coven@chat.shakespeare.lit
'
,
type
:
'
cancel
'
})
.
c
(
'
service-unavailable
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
this
.
chatboxesview
.
views
[
'
problematic@muc.localhost
'
];
view
.
onChatRoomPresence
(
presence
,
{
'
nick
'
:
'
dummy
'
});
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
expect
(
$chat_content
.
text
()).
toBe
(
"
This room has reached it's maximum number of occupants
"
);
},
converse
));
},
converse
));
},
converse
));
}));
tests_main.js
View file @
7c1a9242
...
...
@@ -2,7 +2,7 @@ require(["jquery", "spec/MainSpec"], function($) {
$
(
function
(
$
)
{
var
jasmineEnv
=
jasmine
.
getEnv
();
jasmineEnv
.
updateInterval
=
50
0
;
jasmineEnv
.
updateInterval
=
25
0
;
var
htmlReporter
=
new
jasmine
.
HtmlReporter
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment