mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Added newpackage-notify to finally implement
new package notifications that people can ask for on their user page. This script should run on a daily cronjob. A few spelling stupidity fixes as well.
This commit is contained in:
parent
6adf639a34
commit
45e5883a15
3 changed files with 91 additions and 5 deletions
86
support/scripts/newpackage-notify
Executable file
86
support/scripts/newpackage-notify
Executable file
|
@ -0,0 +1,86 @@
|
||||||
|
#!/usr/bin/python -O
|
||||||
|
# $Id$
|
||||||
|
# This program is intended to be run as a once-a-day cronjob, it
|
||||||
|
# sends a batched email containing the names of all new pacakges in
|
||||||
|
# the AUR, added within the last 24 hours, to those who have requested
|
||||||
|
# it on their account page.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import MySQLdb, MySQLdb.connections
|
||||||
|
import ConfigParser
|
||||||
|
from time import time
|
||||||
|
|
||||||
|
#some options
|
||||||
|
SENDMAIL="/usr/sbin/sendmail"
|
||||||
|
|
||||||
|
#Copied and pasted from tupkg updater:
|
||||||
|
###########################################################
|
||||||
|
# Deal with configuration
|
||||||
|
###########################################################
|
||||||
|
|
||||||
|
conffile = '/home/aur/tupkgs.conf'
|
||||||
|
|
||||||
|
if not os.path.isfile(conffile):
|
||||||
|
print "Error: cannot access config file ("+conffile+")"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
config = ConfigParser.ConfigParser()
|
||||||
|
config.read(conffile)
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Step 1, figure out the unix time 24 hours ago
|
||||||
|
starttime = time() - 24*60*60
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Step 2, do all the mysql mucking
|
||||||
|
dbconnection = MySQLdb.connect(host=config.get('mysql', 'host'), user=config.get('mysql', 'username'), passwd=config.get('mysql', 'password'), db=config.get('mysql', 'db'))
|
||||||
|
q = dbconnection.cursor()
|
||||||
|
|
||||||
|
q.execute("SELECT Packages.Name, Packages.ID FROM Packages WHERE Packages.SubmittedTS >= %d AND Packages.DummyPkg = 0"%starttime)
|
||||||
|
packages = q.fetchall()
|
||||||
|
|
||||||
|
q.execute("SELECT Users.Email FROM Users WHERE Users.NewPkgNotify = 1")
|
||||||
|
emails = q.fetchall()
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# Step 3, generate the message, depending on what we found
|
||||||
|
|
||||||
|
#generate the headers to say where it is going
|
||||||
|
message = "To: \nBcc: "
|
||||||
|
emails_list=[]
|
||||||
|
for i in emails:
|
||||||
|
emails_list.append(i[0])
|
||||||
|
message = message + (", ".join(emails_list))
|
||||||
|
|
||||||
|
#where it came from + other headers
|
||||||
|
message = message + "\nReply-to: nobody@archlinux.org\nFrom: aur-notify@archlinux.org\nX-Mailer: Python\nX-MimeOLE: Produced by AUR\n"
|
||||||
|
|
||||||
|
#the subject
|
||||||
|
message = message + "Subject: AUR New Package Notification\n\n"
|
||||||
|
|
||||||
|
#TODO: translations of message wouldn't kill anyone, but this would then need to find out the users language pref too
|
||||||
|
#Ok now the body
|
||||||
|
message = message + "Packages added to the AUR within the last 24 hours include:\n\n"
|
||||||
|
pkgs_list=[]
|
||||||
|
for i in packages:
|
||||||
|
message = message + i[0] + " ( http://aur.archlinux.org/packages.php?do_Details=1&ID=%d )\n"%i[1]
|
||||||
|
message = message + '''
|
||||||
|
---
|
||||||
|
You received this email because you chose to receive new package
|
||||||
|
notifications on your user options page in the AUR. If you no
|
||||||
|
longer wish to receive this daily mailing, please go to your
|
||||||
|
user options page in the AUR (http://aur.archlinux.org) and
|
||||||
|
uncheck "New Package Notify".
|
||||||
|
|
||||||
|
'''
|
||||||
|
#print message #that's for debug
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# Step 4, mail that sucker
|
||||||
|
mailer = os.popen("%s -t" % SENDMAIL, 'w')
|
||||||
|
mailer.write(message)
|
||||||
|
mailer.close()
|
||||||
|
|
||||||
|
# vim:noet:ts=2 sw=2 ft=python
|
|
@ -93,7 +93,7 @@ if ($_REQUEST["add_Comment"]) {
|
||||||
$q.= "WHERE Packages.ID = ".intval($_REQUEST["ID"]);
|
$q.= "WHERE Packages.ID = ".intval($_REQUEST["ID"]);
|
||||||
$result = db_query($q, $dbh);
|
$result = db_query($q, $dbh);
|
||||||
$row = mysql_fetch_assoc($result);
|
$row = mysql_fetch_assoc($result);
|
||||||
$body = __("A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control.",array($row['Name'],$_REQUEST["ID"]));
|
$body = __("A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou received this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control.",array($row['Name'],$_REQUEST["ID"]));
|
||||||
$body = wordwrap($body, 70);
|
$body = wordwrap($body, 70);
|
||||||
$bcc = implode(', ', $bcc);
|
$bcc = implode(', ', $bcc);
|
||||||
$headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
|
$headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
|
||||||
|
|
|
@ -89,10 +89,10 @@ $_t["en"]["You've found a bug if you see this...."] = "You've found a bug if you
|
||||||
# $_t["de"]["Category"] = "--> Deutsche Ãœbersetzung hier. <--";
|
# $_t["de"]["Category"] = "--> Deutsche Ãœbersetzung hier. <--";
|
||||||
$_t["pl"]["You've found a bug if you see this...."] = "Jeżeli to widzisz, to znalazłeś błąd...";
|
$_t["pl"]["You've found a bug if you see this...."] = "Jeżeli to widzisz, to znalazłeś błąd...";
|
||||||
|
|
||||||
$_t["en"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control.";
|
$_t["en"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou received this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control.";
|
||||||
# $_t["es"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Traducción española aquí. <--";
|
# $_t["es"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou received this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Traducción española aquí. <--";
|
||||||
# $_t["fr"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Traduction française ici. <--";
|
# $_t["fr"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou received this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Traduction française ici. <--";
|
||||||
# $_t["de"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Deutsche Übersetzung hier. <--";
|
# $_t["de"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou received this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Deutsche Übersetzung hier. <--";
|
||||||
|
|
||||||
$_t["en"]["AUR Comment Notification for %s"] = "AUR Comment Notification for %s";
|
$_t["en"]["AUR Comment Notification for %s"] = "AUR Comment Notification for %s";
|
||||||
# $_t["es"]["AUR Comment Notification for %s"] = "--> Traducción española aquí. <--";
|
# $_t["es"]["AUR Comment Notification for %s"] = "--> Traducción española aquí. <--";
|
||||||
|
|
Loading…
Add table
Reference in a new issue