]> Dogcows Code - chaz/chatty/blobdiff - lib/Chatty/Controller/Chat.pm
validate sent chat to avoid spurious join messages
[chaz/chatty] / lib / Chatty / Controller / Chat.pm
index 9be0e796e28449eefb4e31fbaad02c3e7cef997d..01cb23410c479a48155ffae17e10fecc46e5940f 100644 (file)
@@ -92,7 +92,18 @@ sub view :Chained(room) :PathPart('') :Args(1) {
        $c->stash(room => $c->model('DB::Room')->find($room));
        $c->detach('/missing') if !$c->stash->{room};
 
-       $c->stash(messages => [$c->model('DB::Message')->search(room => $room)]);
+       my $name = $c->user->obj->username;
+
+       my $msg = $c->req->param('msg');
+       if (defined $msg) {
+               return if $msg eq '';
+               $c->model('Meteor')->addMessage($room, "$name: $msg");
+               $c->stash->{json} = \1;
+               $c->forward('View::JSON');
+               return;
+       }
+
+       $c->model('Meteor')->addMessage($room, "** $name has entered **");
 }
 
 =head1 AUTHOR
This page took 0.016426 seconds and 4 git commands to generate.