- my ($request, $response)=@_;
- return RC_OK if $response->code;
-
- eval {
- httpdie $response, 'All requests must use the POST http method' unless $request->method eq 'POST';
- my $user=$request->header('Username');
-
- my $destination=$request->header('X-Destination') // httpdie $response, 'Missing destination address';
- my ($driver, $address)=shellwords $destination;
-
- my $content=$request->content // httpdie $response, 'Content is undef';
-
- if ($driver eq 'HTTP') {
- $responses{$user}//=[];
- push $responses{$user}, $content;
- if (exists $waiting_userrequests{$user}) {
- $waiting_userrequests{$user}->continue;
- delete $waiting_userrequests{$user}
- }
- } else {
- unless ($ok_user_addresses{"$user $driver $address"}) {
- $response->code(HTTP_FORBIDDEN);
- $response->message("$user is not allowed to send messages to $address");
- return
- }
-
- POE::Kernel->post($driver, 'send_message', $address, $content) or $log->error("Driver not found: $driver");
- }
-
- $response->code(HTTP_NO_CONTENT);
- $response->message('Message sent');
- };
-
- $log->error("ERROR: $@") if $@ && $@ !~ /^Bad Request /;
- $log->debug('Responding to send from $user with '.$response->code.' '.$response->message);
- RC_OK
+ my ($request, $response)=@_;
+ return RC_OK if $response->code;
+
+ eval {
+ httpdie $response, 'All requests must use the POST http method' unless $request->method eq 'POST';
+ my $user=$request->header('Username');
+
+ my $destination=$request->header('X-Destination') // httpdie $response, 'Missing destination address';
+ my ($driver, $address)=shellwords $destination;
+
+ my $content=$request->content // httpdie $response, 'Content is undef';
+
+ if ($driver eq 'HTTP') {
+ $responses{$user}//=[];
+ push @{$responses{$user}}, $content;
+ if (exists $waiting_userrequests{$user}) {
+ $waiting_userrequests{$user}->continue;
+ delete $waiting_userrequests{$user}
+ }
+ } else {
+ unless ($ok_user_addresses{"$user $driver $address"}) {
+ $response->code(HTTP_FORBIDDEN);
+ $response->message("$user is not allowed to send messages to $address");
+ return
+ }
+
+ POE::Kernel->post($driver, 'send_message', $address, $content) or $log->error("Driver not found: $driver");
+ }
+
+ $response->code(HTTP_NO_CONTENT);
+ $response->message('Message sent');
+ };
+
+ $log->error("ERROR: $@") if $@ && $@ !~ /^Bad Request /;
+ $log->debug('Responding to send from $user with '.$response->code.' '.$response->message);
+ RC_OK