| | @@ -231,10 +231,19 @@ |
| 231 | 231 | @ This is short name used to identifies the repository in the |
| 232 | 232 | @ Subject: line of email alerts. Traditionally this name is |
| 233 | 233 | @ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]". |
| 234 | 234 | @ (Property: "email-subname")</p> |
| 235 | 235 | @ <hr> |
| 236 | + |
| 237 | + onoff_attribute("Automatic Email Exec", "email-autoexec", |
| 238 | + "eauto", 0, 0); |
| 239 | + @ <p>If enabled, then email notifications are automatically |
| 240 | + @ dispatched after some webpages are accessed. This eliminates the |
| 241 | + @ need to have a cron job running to invoke "fossil email exec" |
| 242 | + @ periodically. |
| 243 | + @ (Property: "email-autoexec")</p> |
| 244 | + @ <hr> |
| 236 | 245 | |
| 237 | 246 | multiple_choice_attribute("Email Send Method", "email-send-method", "esm", |
| 238 | 247 | "off", count(azSendMethods)/2, azSendMethods); |
| 239 | 248 | @ <p>How to send email. The "Pipe to a command" |
| 240 | 249 | @ method is the usual choice in production. |
| | @@ -1658,11 +1667,11 @@ |
| 1658 | 1667 | #define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */ |
| 1659 | 1668 | |
| 1660 | 1669 | #endif /* INTERFACE */ |
| 1661 | 1670 | |
| 1662 | 1671 | /* |
| 1663 | | -** Send alert emails to all subscribers |
| 1672 | +** Send alert emails to all subscribers. |
| 1664 | 1673 | */ |
| 1665 | 1674 | void email_send_alerts(u32 flags){ |
| 1666 | 1675 | EmailEvent *pEvents, *p; |
| 1667 | 1676 | int nEvent = 0; |
| 1668 | 1677 | Stmt q; |
| | @@ -1754,5 +1763,30 @@ |
| 1754 | 1763 | } |
| 1755 | 1764 | send_alerts_done: |
| 1756 | 1765 | email_sender_free(pSender); |
| 1757 | 1766 | db_end_transaction(0); |
| 1758 | 1767 | } |
| 1768 | + |
| 1769 | +/* |
| 1770 | +** Check to see if any email notifications need to occur, and then |
| 1771 | +** do them. |
| 1772 | +** |
| 1773 | +** This routine is called after certain webpages have been run and |
| 1774 | +** have already responded. |
| 1775 | +*/ |
| 1776 | +void email_auto_exec(void){ |
| 1777 | + int iJulianDay; |
| 1778 | + if( g.db==0 ) return; |
| 1779 | + db_begin_transaction(); |
| 1780 | + if( !email_tables_exist() ) goto autoexec_done; |
| 1781 | + if( !db_get_boolean("email-autoexec",0) ) goto autoexec_done; |
| 1782 | + if( !db_exists("SELECT 1 FROM pending_alert") ) goto autoexec_done; |
| 1783 | + email_send_alerts(0); |
| 1784 | + iJulianDay = db_int(0, "SELECT julianday('now')"); |
| 1785 | + if( iJulianDay>db_get_int("email-last-digest",0) ){ |
| 1786 | + email_send_alerts(SENDALERT_DIGEST); |
| 1787 | + db_set_int("email-last-digest", iJulianDay, 0); |
| 1788 | + } |
| 1789 | + |
| 1790 | +autoexec_done: |
| 1791 | + db_end_transaction(0); |
| 1792 | +} |
| 1759 | 1793 | |