X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/5ed773c6434c4e992898720d3033ce14e484a68b..ec371adab1109b338a3de473298b41140ec5017e:/IkiWiki/Plugin/notifyemail.pm?ds=inline diff --git a/IkiWiki/Plugin/notifyemail.pm b/IkiWiki/Plugin/notifyemail.pm index 58f0c9920..b50a22a00 100644 --- a/IkiWiki/Plugin/notifyemail.pm +++ b/IkiWiki/Plugin/notifyemail.pm @@ -62,9 +62,23 @@ sub subscribe ($$) { length $pagespec ? $pagespec." or ".$addpagespec : $addpagespec); } +# Called by other plugins to subscribe an email to a pagespec. +sub anonsubscribe ($$) { + my $email=shift; + my $addpagespec=shift; + if (IkiWiki::Plugin::passwordauth->can("anonuser")) { + my $user=IkiWiki::Plugin::passwordauth::anonuser($email); + if (! defined $user) { + error(gettext("Cannot subscribe your email address without logging in.")); + } + subscribe($user, $addpagespec); + } +} + sub notify (@) { my @files=@_; return unless @files; + return if $config{rebuild}; eval q{use Mail::Sendmail}; error $@ if $@; @@ -123,11 +137,20 @@ sub notify (@) { if (pagetype($file) eq '_comment') { $subject=gettext("comment notification:")." ".$pagedesc; } + my $prefsurl=IkiWiki::cgiurl_abs(do => 'prefs'); + if (IkiWiki::Plugin::passwordauth->can("anonusertoken")) { + my $token=IkiWiki::Plugin::passwordauth::anonusertoken($userinfo->{$user}); + $prefsurl=IkiWiki::cgiurl_abs( + do => 'tokenauth', + name => $user, + token => $token, + ) if defined $token; + } my $template=template("notifyemail.tmpl"); $template->param( wikiname => $config{wikiname}, url => $url, - prefsurl => $config{cgiurl}."?do=prefs", + prefsurl => $prefsurl, showcontent => $showcontent, content => $content, );