Changeset 12569 in project


Ignore:
Timestamp:
11/22/08 04:05:29 (13 years ago)
Author:
azul
Message:

Fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/svnwiki-mail/trunk/svnwiki-mail.scm

    r12542 r12569  
    626626(define (mail-page->id env path . rest)
    627627  (let-optionals rest ((get-data (lambda (id) (mail-db-run env "SELECT page FROM pages WHERE id = ?;" id))))
    628     (let ((base (stream-filter (disjoin char-alphabetic? char-numeric? (cut string-index "-_/" <>))
    629                                (string->stream path))))
     628    (let* ((path-canonical (string->stream (svnwiki-mail-path-canonical path)))
     629           (base (stream-filter (disjoin char-alphabetic? char-numeric? (cut string-index "-_/" <>))
     630                                path-canonical)))
    630631      (let loop ((current #f))
    631632        (let* ((id (if current (format #f "~A-~A" (stream->string base) current) (stream->string base)))
    632633               (page (get-data id)))
    633634          (if (or (stream-null? page)
    634                   (string=? (vector-ref (stream-car page) 0) path))
     635                  (stream= char=? (string->stream (vector-ref (stream-car page) 0)) path-canonical))
    635636            id
    636637            (loop (+ (or current -1) 1))))))))
     
    678679
    679680(define (notify-subscribers env)
    680   (format (current-error-port) "XXXX: called~%")
    681   (let-from-environment env (path user-input new-rev)
    682     (svnwiki-report-progress env (svnwiki-translate env "Notify-subscribers running: ~A~%") path)
    683     (let ((page-data (mail-db-run env "SELECT page, id, last_revision FROM pages WHERE page = ?;" (svnwiki-mail-path-canonical path))))
    684       (when (stream-null? page-data)
    685         (mail-db-run env "INSERT INTO pages VALUES ( ?, ?, 0 );" (svnwiki-mail-path-canonical path) (mail-page->id env path))
    686         (set! page-data (mail-db-run env "SELECT page, id, last_revision FROM pages WHERE page = ?;" (svnwiki-mail-path-canonical path))))
    687       (svnwiki-report-progress env (svnwiki-translate env "Sending email notifications: ~A~%") path)
    688       (notify-subscribers-normal
    689         env
    690         (vector-ref (stream-car page-data) 1)
    691         (vector-ref (stream-car page-data) 2))
    692       (notify-subscribers-discuss
    693         (let ((path (make-discuss path)))
    694           (environment-capture env (path)))
    695         (vector-ref (stream-car page-data) 1)
    696         (vector-ref (stream-car page-data) 2))
    697       (mail-db-run env "UPDATE pages SET last_revision = ? WHERE page = ?;"
    698                    new-rev
    699                    (svnwiki-mail-path-canonical path))
    700       (format (current-error-port) "Notifications sent~%"))))
     681  (let-from-environment env (path-in path user-input new-rev)
     682    (format (current-error-port) "XXXX notify-subscribers: ~A: ~A~%" path-in path)
     683    (unless (or (string=? path "")
     684                (directory? (svnwiki-make-pathname path-in path)))
     685      (let ((page-data (mail-db-run env "SELECT page, id, last_revision FROM pages WHERE page = ?;" (svnwiki-mail-path-canonical path))))
     686        (when (stream-null? page-data)
     687          (mail-db-run env "INSERT INTO pages VALUES ( ?, ?, 0 );" (svnwiki-mail-path-canonical path) (mail-page->id env path))
     688          (set! page-data (mail-db-run env "SELECT page, id, last_revision FROM pages WHERE page = ?;" (svnwiki-mail-path-canonical path))))
     689        (svnwiki-report-progress env (svnwiki-translate env "Sending email notifications: ~A~%") path)
     690        ((if (svnwiki-is-discuss? path)
     691           notify-subscribers-discuss
     692           notify-subscribers-normal)
     693         env
     694         (vector-ref (stream-car page-data) 1)
     695         (vector-ref (stream-car page-data) 2))
     696        (mail-db-run env "UPDATE pages SET last_revision = ? WHERE page = ?;"
     697                     new-rev
     698                     (svnwiki-mail-path-canonical path))
     699        (format (current-error-port) "Notifications sent~%")))))
    701700
    702701(define (stream-string-max str len)
     
    780779        ; paths in the subversion logs start with a slash.
    781780        (let ((entry (assoc (format #f "/~A" path) (first rev))))
    782           (assert (and 'notify-subscribers-normal-parse-revision entry))
     781          (unless entry
     782            (error "Failed to find" path (first rev)))
    783783          (stream
    784784            (make-changed-file
     
    789789              (fifth rev))))))
    790790    (cut make-mail-gateway-address <> "xsvnwiki-mail/notifications/")
    791     (lambda (rev address id gateway-address env-new original-file)
     791    (lambda (rev address id gateway-address env original-file)
    792792      (format #t "From: ~A~%" (make-mail-gateway-address env "xsvnwiki-mail/notifications/"))
    793793      (let ((description
     
    804804              (stream->string (stream-string-max description 60))))
    805805      (format #t "To: ~A~%" address)
    806       (format #t "List-ID: ~A~%" (make-mail-list-id env-new (format "~A.notifications" id)))
     806      (format #t "List-ID: ~A~%" (make-mail-list-id env (format "~A.notifications" id)))
    807807      (format #t "List-Post: NO~%"))
    808808    (lambda (env address rev)
     
    909909(svnwiki-extension-define 'files-actions-links 'mail mail-subscribe-link)
    910910(svnwiki-extension-define 'commit-handler 'mail subscribe-address-commit)
    911 (svnwiki-extension-define 'update-notify 'mail notify-subscribers)
     911(svnwiki-extension-define 'update-notify-recursive 'mail notify-subscribers)
    912912(svnwiki-extension-define 'dynamic 'mail mail-request-handle)
Note: See TracChangeset for help on using the changeset viewer.