[EP-tech] Sending email when item is made live

Stenger, Avischai avischai.stenger at ulb.tu-darmstadt.de
Wed Apr 22 10:40:27 BST 2020


Hallo Yuri,

tnks for the Infos. I thing I found a different way, with less code-changing. I am still testing it.  I modified a bit the :
CGI Script (and other non-screen functions)
From a CGI script, you can send a message to a user via the repository object, as such you need to specify the user, which need not be the current user:

  my $repository = new EPrints::Session;
  my $db = $repository->database;
  my $current_user = $repository->current_user();
  $db->save_user_message(
            $current_user->get_value( "userid" ),   #Userid to receive the message
            "message",                              #Message type
            $repo->html_phrase("some_phrase_identifier", (              #the message body, in this instance a phrase identifier
                        "name" => $current_user->render_value( "name" ) # pin name/value pairs as required for the phrase;
                        )
            )
  );



And it looks like it will work fine.


Regards

A.

Am 22.04.2020 um 10:56 schrieb Yuri Carrer via Eprints-tech <eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>>:

https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FSending_user_messages&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=e34vrrmD6xsD4nzdm6u31CZVaa6sWETX8vAnOpjN3DQ%3D&amp;reserved=0

you want the message if the user clicked a button on screen, the link
you cited act on a status change which is instead an asyncronous
operation (it is performed outside the page flow).

You've to replace the actual screen action (for example "Move to the
repository" which is EPrint::Move (*)) with another one that perform the
add_message() after calling the action directly

(*)
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprints%2Feprints%2Fblob%2F3.3%2Fperl_lib%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FMove.pm&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=WqmiJchiJoeMx%2Fc7mEkJFXzmpAWcRYTXuoXU5FbA1YA%3D&amp;reserved=0

sub action_move_archive
{
    my( $self ) = @_;

    my $ok = $self->{processor}->{eprint}->move_to_archive;

    $self->add_result_message( $ok );
}

$self->{processor}->{eprint}->move_to_archive perform the status change
and activate the trigger but you can't know about trigger result because
it is done elsewhere (the epindexer deamon!) <- important!

At the end, you've to add the event (not the trigger, take a look to the
doi datacite plugin on how to do it (*)) in the code of in the screen
plugin and then the event, when triggered, will have the pluginid and
action set, so you can check where the triggered event came from, and
send/not send the email based on your logic.

(*)
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2FDataCiteDoi%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FStaff%2FCoinDOI.pm%23L97&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=6irMWqp3qb9Y600rI5TQV%2FO0K3IuNZA%2FJYGppoHurk8%3D&amp;reserved=0

            $repository->dataset( "event_queue" )->create_dataobj({
                pluginid => "Event::DataCiteEvent",
                action => "datacite_doi",
                params => [$eprint->internal_uri],
            }); <- here replace with Eprint::Move and move_to_archive

Il 22/04/20 10:05, Stenger, Avischai via Eprints-tech ha scritto:
Hi 2 all,

I am using this Method: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FSending_email_when_item_is_made_live_or_deposited&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=AWxbmMq3dile1J4uBJPaZqiS5LhflOMaWfgdYdmqNqQ%3D&amp;reserved=0

And it work fine, but I cannot get a „mailsend_OK /mailsend_Not_OK“  message to be shown on the user Screen. How do I get this done? I find no „object" with the add_message() funtion


Tnks and a healthy day


avi


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=jwnYlvuesYIRlBh9JY9DZ95NaJz68yolTSqPdh5EXiI%3D&amp;reserved=0
*** EPrints community wiki: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=qJB%2FrSqWGvTg%2FFHcQDCtAauuL%2FAvYh9JGb8qOaoTMf8%3D&amp;reserved=0

--
Yuri Carrer

 CAB - Centro di Ateneo per le Biblioteche, Università di Padova
 Tel: 049/827 9712 - Via Beato Pellegrino, 28 - Padova


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=jwnYlvuesYIRlBh9JY9DZ95NaJz68yolTSqPdh5EXiI%3D&amp;reserved=0
*** EPrints community wiki: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cac0bbc9f4871480c3d4308d7e6a131b5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=qJB%2FrSqWGvTg%2FFHcQDCtAauuL%2FAvYh9JGb8qOaoTMf8%3D&amp;reserved=0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20200422/5bc47494/attachment-0001.html 


More information about the Eprints-tech mailing list