The foswiki svn repository will become read-only on Friday 8/8. Developers should register for a http://github.com/ account for commit access to foswiki.

Item1302: mailnotify ignores -news operand

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Extension MailerContrib Main.KennethLavrsen
The WebNotify topic of each web offers the option of creating newsletters based on topics, which are to be sent out every time the mailnotify script is called with the -news operand.

For example, according to the documentation, assuming the Common web in WebNotify, it should be possible to have:

Subscribers for change reports.
  • email1
  • email2
  • email3

Subscribers for newsletters
  • email4 : NewsLetter!
  • email5 : NewsLetter!

We would create two cron jobs, like this:
0 1 * * 4 (cd /home/.../bin; perl ../tools/mailnotify -news Common)
0 0 * * * (cd /home/.../bin; perl ../tools/mailnotify -q)

which means that newsletters (first line) listed in the Common web would be sent out only once per week, and the second line sends change reports out daily.

--> Unfortunately, the newsletters are sent out daily.

the "-news" operand is ignored in the mailnotify script, treating it like a web that is to be excluded.

PROPOSED CORRECTION
  1. Detect -news in the mailnotify script and pass it as an operand to the MailerContrib.pm module.
  2. Process newsletters ONLY when the flag is provided in the command.
  3. Process change reports ONLY when the flag is NOT provided in the command.

-- RaymondLutz


(1) is a bug, caused by http://twiki.org/cgi-bin/view/Codev.EnhanceMailerContribToAllowExclusionOfWebs which was obviously implemented without reference to the documentation frown

(2) and (3) are proposals to change the behaviour of the script. Rather than changing the spec, I would rather you added a -nochanges parameter to suppress change notification.

-- CrawfordCurrie - 24 Jul 2009
Your comment regarding (2) and (3) does not make much sense because the -news parameter currently does not work at all. By allowing this parameter to be passed, we can honor the original intention of the documentation. No one can be using this parameter right now because it does not work, and therefore, there is no "current behaviour" that is being changed.

Adding yet another parameter is not necessary, nor is it sufficient. The -news parameter implies that specified newsletters will be processed even if there are no changes. We don't want those newsletters processed as if they are change reports. The problem is not that the change reports are processed with the newsletters (as nothing is processed now) but that the newsletters are processed with the change reports (and they are now, because the -news parameter does not work) Therefore, I don't believe the idea of -nochanges will accomplish the desired result (although the idea of guarding current behavior is a respectable goal.) -nochanges is implied by -news. Is there a reason to have -nochanges and not -news?

-- 19 Aug 2009 - 18:55:28 - RaymondLutz

I took a look at this.

I went back to before the http://twiki.org/cgi-bin/view/Codev.EnhanceMailerContribToAllowExclusionOfWebs was implemented.

I looked at the code. I tried it in practical life.

The -news option has never been implemented. It has been documented but the newsletters are processed with or without this switch. I guess Lynnwood that originally requested the feature did not notice because he probably ran with the -news in the faith that it did good.

But I cannot see it ever worked.

And it would for sure be nice if it did. But for now we should wipe this wrong documentation. Or we need to implement it as documented.

Personally I would rather have a switch that can choose an alternative to WebNotify. Then I can completely freely control what runs when.

-- KennethLavrsen - 15 Oct 2009

I am taking a stab at this now.

I agree with Raymond. When you read the spec. Both of current version and older versions the -news switch leaves no doubt in my head that it means switching into new mode processing the ? and ! suffixed items.

And therefore also meaning that the lack of -news means process only topics without the ? and ! suffix.

The -nochanges is not the same at all. Remember that the -news mode is about including the entire topic or not. And the changed or not changed is only a matter of suffixing ! vs ?.

There is one problem with the specified -news and that is the timestamping.

If you run a daily changes script. And a weekly news letter using the ? suffix - then you will only get the changes since last non-news run of the script. And that is probably not what you want. You will want the changes since the last news run. Or do you?

I also see a race condition. If you want to run like it is today. Ie a run means both news and non-news you would have to run the script twice. A topic may change between the two runs. It can take many minutes - even hours to complete a script run if you have many subscribers.

I need to think this through a little more with respect to this part. I can see a couple of solutions. Either use separate time stamps for news and none-news. Or drop the -news mode and go for some new and smarter options.

I already have he code running here that implements exactly as spec'ed. So I have put myself and Being Worked On - Waiting for me. But I would like some ideas and feedback on the spec and desired behaviour. Just checking in as spec'ed is not OK. The old spec sucks.

On the syntax I believe we are saved by the fact that as far as I can remember Webnames have to start by a capital letter so it is OK to use -news and -nochanges. It is still possible to use -News also if you happen to have a News web.

-- KennethLavrsen - 15 Oct 2009

I have some code running now where

option Behaviour
none Send only changed. Ignore the ! and ? suffixed
-news Send both changed and news
-nochanges Send nothing. But timestamp gets reset
-nochanges and -news Send only news

So a bit odd. The -news to keep existing spec. And the -nochanges as suggested by Crawford. This will fly. This makes sense. But is it possible to really understand? Maybe with some examples.

Still a little in doubt about the time stamping though. My code still time stamps unconditionally and one stamp common for changes and news. But as long as you can run them simultaneously this may be OK.

There is still the problem if someone both uses normal changes and ? and ! suffix. The ! is OK as it does not use the timestamp. The conflict is between the ? suffix and the none-news runs where the news run can end up missing changes.

Maybe the best is to just drop the -news and have two options -nonews and -nochanges. More logical. Those with a -news switch that they love and live with even if it does nothing will find such a change compatible.

Ie

option Behaviour
none Send both changes and news. Like today
-nonews Send only changes
-nochanges Send only news
-nochanges and -nonews Send nothing but resets the timestamp to now. Silly but does no harm.
-news in any combination ignore the setting like we have always done

-- KennethLavrsen - 15 Oct 2009

Thank you for the work on this issue. The resolution satisfies my requirements.

-- RaymondLutz - 30 Nov 2009

ItemTemplate edit

Summary mailnotify ignores -news operand
ReportedBy RaymondLutz
Codebase 1.0.7
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component MailerContrib
Priority Normal
CurrentState Closed
WaitingFor KennethLavrsen
Checkins Foswikirev:5288 Foswikirev:5289 Foswikirev:5290 Foswikirev:5291 Foswikirev:5292 Foswikirev:5293
TargetRelease patch
ReleasedIn 1.0.8
Topic revision: r15 - 30 Nov 2009, RaymondLutz
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License