Periodic notifications don't seem to work

Nao

  • Dadman with a boy
  • Posts: 16,063
Re: Periodic notifications don't seem to work
« Reply #15, on August 3rd, 2013, 11:55 AM »
Okay, then I'm relieved to see I'm not the only one with problems... :P
Since I did extensive rewrites of the system, I guess I have a correct understanding of it, so to make everything clear, it all boils down to three structures:

- the Notification object, holds a single notification for a member, a certain type. It provides methods that give low-level access to the notification's ID, type, etc.

- the Notifier object, is a 'generic' notification type, which provides plenty of default higher-level methods for a notification plugin (getEmail, etc.)

- the plugin's notifier, inherited from Notifier, called through issue().

Basically, a Notification object always has an associated Notifier.
If you get that, you're already halfway through the system.
Which is, err... Pretty much where I am, lol.

Anyway, I've made a few changes to John's suggestion, and will commit these. Unfortunately, I'm not bothered enough to test my changes, so... Hopefully it works, ah ah.

Code: [Select]
foreach ($notifications as $notifier_name => $notifs)
{
$notifier = weNotif::getNotifiers($notifier_name);
list ($title) = $notifier->getProfile($notifs);

$str .= "\n" . $title . "\n" . str_repeat('=', strlen($title)) . "\n";

foreach ($notifs as $n)
{
list (, $body) = $notifier->getEmail($n);
$str .= $body . "\n\n";
}
}

(getEmail only has one parameter now, because I removed $email_data, which doesn't have any purpose, and thus 'gets in the way', IMHO...)

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,667
Re: Periodic notifications don't seem to work
« Reply #16, on August 3rd, 2013, 01:27 PM »
Commit it and I will test it.
Quote
If you get that, you're already halfway through the system.
Oh, that's the easy part. What's confusing for me is the presence of same-name methods across multiple objects.
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Nao

  • Dadman with a boy
  • Posts: 16,063

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,667

Nao

  • Dadman with a boy
  • Posts: 16,063

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,667

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
The way it's meant to be

Nao

  • Dadman with a boy
  • Posts: 16,063
Re: Periodic notifications don't seem to work
« Reply #22, on September 19th, 2013, 05:00 PM »
Yes you do :P
Welcome back!

I re-disabled the task yesterday right after 'forcing' it, and started work on fixing everything.
I didn't discuss it because, well, it's just plain boring, but here's what new so far.

- Plain text e-mails will now correctly show linebreaks, and better whitespace handling generally.
- There's now an option in Notifications.php to send in HTML, and I've set it to true, because from what I discovered in the sendmail function, HTML e-mails actually send two copies in multipart -- a raw e-mail, and a HTML e-mail. I modified sendmail() to allow for the sender to provide two different bodies for each context; i.e., in the case of notifications, we're sending both versions available. The only drawback is that we have to run both of these through prettify_urls()... Ah, well... I guess if you want it, you can always use the mail queue.
- I've modified a lot of the code in sendmail, mostly to make it easier to understand... Well, there's a part that got repeated twice in the original code (including SMF), now it's no longer the case.

The only problem that remains, right now, is with the language files, obviously... Wedge will use the language file from the current user at the moment the scheduled task is triggered.
I'm thinking of loading the users per language file, and then re-loading all language files, but... Well, how am I supposed to do that..?! Maybe there's already a built-in function to help with that in scheduled tasks, but I don't know anything about that area of Wedge, so...

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,667
Re: Periodic notifications don't seem to work
« Reply #24, on September 19th, 2013, 05:15 PM »
Quote
Well, there's a part that got repeated twice in the original code (including SMF), now it's no longer the case.
You removed the hotmaill fix?
Quote
I'm thinking of loading the users per language file, and then re-loading all language files, but... Well, how am I supposed to do that..?!
$needed_language = empty($row['lngfile']) || empty($settings['userLanguage']) ? $settings['language'] : $row['lngfile'];
$emaildata = loadEmailTemplate($message_type, $replacements, $needed_language);
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body']);;

Nao

  • Dadman with a boy
  • Posts: 16,063
Re: Periodic notifications don't seem to work
« Reply #25, on September 19th, 2013, 06:43 PM »
Nope, didn't remove the 'fix', because we need a 7bit-compatible fallback in all e-mail types anyway. The hotmail fix provides that.

Your solution, would it reload the Notifications language files, too..? Because that's where we find the strings for HTML e-mails, isn't it..?

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,667

Nao

  • Dadman with a boy
  • Posts: 16,063
Re: Periodic notifications don't seem to work
« Reply #28, on September 21st, 2013, 01:35 AM »
Bump.

Also. How about triggering scheduled tasks only if the current user's language is the default..? Then at least we can avoid what happened last time.

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,667