From 785e7d69d8513aae11eee7a734e14bb249dd355b Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 10 Sep 2010 16:08:05 -0500 Subject: [PATCH] added forward option --- docs/Inbox.pod | 6 +++++- lib/Lacuna/RPC/Inbox.pm | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/Inbox.pod b/docs/Inbox.pod index 7e774bc8..dc0c28f9 100644 --- a/docs/Inbox.pod +++ b/docs/Inbox.pod @@ -199,6 +199,10 @@ A hash reference of extra options. =head4 in_reply_to -If this message is in reply to another message, then set this option to the message id of the original message. +A message id. If this message is in reply to another message, then set this option to the message id of the original message. + +=head4 forward + +A message id. If this is set, then the attachments of the message id specified will be sent along with the new message.The text of the message will not automatically be forwarded, if that is desired, it is the client's responsibility to include it in the body of the new message. =cut \ No newline at end of file diff --git a/lib/Lacuna/RPC/Inbox.pm b/lib/Lacuna/RPC/Inbox.pm index 5fd0cc01..e5790072 100644 --- a/lib/Lacuna/RPC/Inbox.pm +++ b/lib/Lacuna/RPC/Inbox.pm @@ -77,7 +77,15 @@ sub send_message { if ($options->{in_reply_to}) { my $reply_to = Lacuna->db->resultset('Lacuna::DB::Result::Message')->find($options->{in_reply_to}); unless ($empire->id ~~ [$reply_to->to_id, $reply_to->from_id]) { - confess [1010, 'You cannot set in_reply_to to a message id that you cannot read.']; + confess [1010, 'You cannot reply to a message id that you cannot read.']; + } + } + my $attachments = {}; + if ($options->{forward}) { + my $forward = Lacuna->db->resultset('Lacuna::DB::Result::Message')->find($options->{forward}); + unless ($empire->id ~~ [$forward->to_id, $forward->from_id]) { + confess [1010, 'You cannot forward a message id that you cannot read.']; + $attachments = $forward->attachments; } } my @sent; @@ -114,7 +122,7 @@ sub send_message { } } if ($send_count > 100) { - confess [1010, "You have already sent the maximum number of messages you can send for one day."]; + confess [1010, "You have already sent the maximum number (100) of messages you can send for one day."]; } foreach my $to (@to) { if ($to->id == 1) { @@ -128,6 +136,7 @@ sub send_message { in_reply_to => $options->{in_reply_to}, recipients => \@sent, tag => 'Correspondence', + attachments => $attachments, ); } } -- 2.51.2