EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #08140


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

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


In effect, each trigger is an ordered list of function pointers. It's a way to add stuff a bit more cleanly and an evolved version of the earlier approach of having configurable "callback" functions all over the place which worked until 2 plugins both needed to use the same one.


On 22/04/2020 12:23, Yuri Carrer via Eprints-tech wrote:
Good to know! I thought the trigger, like indexing and coindoi events,
was written in the queue table, i was wrong.

Il 22/04/20 11:48, Christopher Gutteridge ha scritto:
overriding action_move_archive is a bit yucky and should be a last
resort.

The trigger "eprint_status_change" will be called as part of the
process, not by the indexer so you could just register a trigger and
do the user message in it if the old status was buffer and the new
status is archive.


On 22/04/2020 09:56, Yuri Carrer via Eprints-tech wrote:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FSending_user_messages&amp;data=01%7C01%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=7EVxhmccw%2B8%2FTI8D7JflXZQUwL2mH%2BZ5iF%2Bsa%2FbTfAA%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=YNoKBF7jJmd9wbKLqZJdz338jRVau%2Fl0ZxHgVXCxDbQ%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=YxZA3VNJv4BUuf5ZJUfkLPjLLnoFBUuSWQOK%2BBouQvk%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=viH%2BScC2Ql%2BFaUIDd1l%2BSfsZdbDCeF6XJMc4nvydy%2Fg%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=1duiu1H236kq8nD957SnqL%2F8kJ3oQiuYt9wuDBnxHZo%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=MfNK7v%2Ff3tDpZMAZch0ysCmEFCtK7BhViO%2F3IDrc1CY%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=1duiu1H236kq8nD957SnqL%2F8kJ3oQiuYt9wuDBnxHZo%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=MfNK7v%2Ff3tDpZMAZch0ysCmEFCtK7BhViO%2F3IDrc1CY%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=1duiu1H236kq8nD957SnqL%2F8kJ3oQiuYt9wuDBnxHZo%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%7C%7C48c4f814aeb348348ed608d7e6bbd23c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=MfNK7v%2Ff3tDpZMAZch0ysCmEFCtK7BhViO%2F3IDrc1CY%3D&amp;reserved=0

--
Christopher Gutteridge <totl@soton.ac.uk>
You should read our team blog at http://blog.soton.ac.uk/webteam/