427 |
|
|
428 |
header['Date'] = rfc2822_date() |
header['Date'] = rfc2822_date() |
429 |
header['From'] = bug['reporter'] |
header['From'] = bug['reporter'] |
430 |
header['To'] = to_addrs.join(', ') |
# header['From'] = "BugCommunicator <#{@config.address}>" |
431 |
|
# header['To'] = to_addrs.join(', ') |
432 |
|
header['To'] = "BugCommunicator <#{@config.address}>" |
433 |
header['Subject'] = "[#{project} ##{bug.bug_id}] " + |
header['Subject'] = "[#{project} ##{bug.bug_id}] " + |
434 |
rfc2047_q_encoding(bug['summary']) |
rfc2047_q_encoding(bug['summary']) |
435 |
header['Sender'] = @config.admin_address |
header['Sender'] = @config.admin_address |
436 |
header['Message-ID'] = rfc2822_msg_id() |
header['Message-ID'] = rfc2822_msg_id() |
437 |
header['Mail-Followup-To'] = @config.address |
header['Mail-Followup-To'] = @config.address |
438 |
header['Mail-Reply-To'] = bug['reporter'] |
# header['Mail-Reply-To'] = bug['reporter'] |
439 |
header['Reply-To'] = @config.address |
# header['Mail-Reply-To'] = @config.address |
440 |
|
# header['Reply-To'] = @config.address |
441 |
header['Mime-Version'] = "1.0 (generated by BugCommunicator #{BUGCOMM_VERSION})" |
header['Mime-Version'] = "1.0 (generated by BugCommunicator #{BUGCOMM_VERSION})" |
442 |
header['X-BugCommunicator-Version'] = BUGCOMM_VERSION |
header['X-BugCommunicator-Version'] = BUGCOMM_VERSION |
443 |
header['X-BugCommunicator-URL'] = @config.url + |
header['X-BugCommunicator-URL'] = @config.url + |
507 |
else |
else |
508 |
header['Content-Type'] = text.header['Content-Type'] |
header['Content-Type'] = text.header['Content-Type'] |
509 |
header['Content-Transfer-Encoding'] = |
header['Content-Transfer-Encoding'] = |
510 |
text.header['Content-Transfer-Enocding'] |
text.header['Content-Transfer-Encoding'] |
511 |
msg.body = text.body |
msg.body = text.body |
512 |
end |
end |
513 |
|
|
518 |
|
|
519 |
# The top page. |
# The top page. |
520 |
def cgi_top(db) |
def cgi_top(db) |
521 |
begin |
mod = Module.new |
522 |
db.lock() |
|
523 |
mod = Module.new |
db.transaction() do |
524 |
url = @config.url |
url = @config.url |
525 |
mod.module_eval do |
mod.module_eval do |
526 |
@@url = url |
@@url = url |
527 |
@@projects = db.projects |
@@projects = db.projects() |
528 |
end |
end |
|
ensure |
|
|
db.unlock() |
|
529 |
end |
end |
530 |
|
|
531 |
compile('top.rhtml', mod) |
compile('top.rhtml', mod) |
532 |
end |
end |
533 |
|
|
535 |
def cgi_project(cgi, db) |
def cgi_project(cgi, db) |
536 |
project, = get_params(cgi.params, |
project, = get_params(cgi.params, |
537 |
['project', BugCommunicator::PROJECT_RE]) |
['project', BugCommunicator::PROJECT_RE]) |
538 |
|
mod = Module.new |
539 |
begin |
|
540 |
db.lock(project) |
db.transaction() do |
|
mod = Module.new |
|
541 |
url = @config.url |
url = @config.url |
542 |
mod.module_eval do |
mod.module_eval do |
543 |
@@url = url |
@@url = url |
545 |
@@selection_fields = db.selection_fields(project) |
@@selection_fields = db.selection_fields(project) |
546 |
@@text_fields = db.text_fields(project) |
@@text_fields = db.text_fields(project) |
547 |
end |
end |
|
compile('project.rhtml', mod) |
|
|
ensure |
|
|
db.unlock |
|
548 |
end |
end |
549 |
|
|
550 |
|
compile('project.rhtml', mod) |
551 |
end |
end |
552 |
|
|
553 |
# Add a project. |
# Add a project. |
583 |
end |
end |
584 |
end |
end |
585 |
|
|
586 |
begin |
cid = nil |
587 |
db.lock(nil, false) |
action = nil |
588 |
|
db.transaction() do |
589 |
if db.include?(project) |
if db.include?(project) |
590 |
raise MalformedRequestError, |
raise MalformedRequestError, |
591 |
"the project `#{project}' already exists" |
"the project `#{project}' already exists" |
593 |
|
|
594 |
action = AddProjectAction.new(address, project, admins, lists) |
action = AddProjectAction.new(address, project, admins, lists) |
595 |
cid = db.store_action(action) |
cid = db.store_action(action) |
|
ensure |
|
|
db.unlock() |
|
596 |
end |
end |
|
|
|
597 |
send_confirmation(cid, action, @config.admin_address) |
send_confirmation(cid, action, @config.admin_address) |
598 |
|
|
599 |
mod = Module.new |
mod = Module.new |
604 |
@@project = nil |
@@project = nil |
605 |
@@to_addrs = to_addrs |
@@to_addrs = to_addrs |
606 |
end |
end |
607 |
|
|
608 |
compile('add-success.rhtml', mod) |
compile('add-success.rhtml', mod) |
609 |
end |
end |
610 |
|
|
618 |
raise MalformedRequestError, "invalid address `#{address}'" |
raise MalformedRequestError, "invalid address `#{address}'" |
619 |
end |
end |
620 |
|
|
621 |
begin |
db.transaction() do |
|
db.lock(nil, false) |
|
|
|
|
622 |
unless db.include?(project) |
unless db.include?(project) |
623 |
raise MalformedRequestError, "no such project `#{project}'" |
raise MalformedRequestError, "no such project `#{project}'" |
624 |
end |
end |
625 |
|
|
626 |
action = RemoveProjectAction.new(address, project) |
action = RemoveProjectAction.new(address, project) |
627 |
cid = db.store_action(action) |
cid = db.store_action(action) |
|
ensure |
|
|
db.unlock() |
|
628 |
end |
end |
629 |
|
|
630 |
send_confirmation(cid, action, @config.admin_address) |
send_confirmation(cid, action, @config.admin_address) |
637 |
@@project = nil |
@@project = nil |
638 |
@@to_addrs = to_addrs |
@@to_addrs = to_addrs |
639 |
end |
end |
640 |
|
|
641 |
compile('remove-success.rhtml', mod) |
compile('remove-success.rhtml', mod) |
642 |
end |
end |
643 |
|
|
645 |
def cgi_config(cgi, db) |
def cgi_config(cgi, db) |
646 |
project, = get_params(cgi.params, |
project, = get_params(cgi.params, |
647 |
['project', BugCommunicator::PROJECT_RE]) |
['project', BugCommunicator::PROJECT_RE]) |
648 |
|
mod = Module.new |
649 |
begin |
|
650 |
db.lock(project) |
db.transaction() do |
|
mod = Module.new |
|
651 |
url = @config.url |
url = @config.url |
652 |
mod.module_eval do |
mod.module_eval do |
653 |
@@url = url |
@@url = url |
657 |
@@admins = db.admins(project) |
@@admins = db.admins(project) |
658 |
@@lists = db.lists(project) |
@@lists = db.lists(project) |
659 |
end |
end |
|
compile('config.rhtml', mod) |
|
|
ensure |
|
|
db.unlock() |
|
660 |
end |
end |
661 |
|
|
662 |
|
compile('config.rhtml', mod) |
663 |
end |
end |
664 |
|
|
665 |
# Browse a bug. |
# Browse a bug. |
667 |
project, bug_id = get_params(cgi.params, |
project, bug_id = get_params(cgi.params, |
668 |
['project', BugCommunicator::PROJECT_RE], |
['project', BugCommunicator::PROJECT_RE], |
669 |
['bug_id', /\A[0-9]+\z/, true]) |
['bug_id', /\A[0-9]+\z/, true]) |
670 |
|
mod = Module.new |
671 |
|
|
672 |
begin |
db.transaction() do |
|
db.lock(project) |
|
|
mod = Module.new |
|
673 |
url = @config.url |
url = @config.url |
674 |
mod.module_eval do |
mod.module_eval do |
675 |
@@url = url |
@@url = url |
682 |
@@followups << db.followup(project, f_id) |
@@followups << db.followup(project, f_id) |
683 |
end |
end |
684 |
end |
end |
|
compile('browse.rhtml', mod) |
|
|
ensure |
|
|
db.unlock() |
|
685 |
end |
end |
686 |
|
|
687 |
|
compile('browse.rhtml', mod) |
688 |
end |
end |
689 |
|
|
690 |
# Search bugs. |
# Search bugs. |
703 |
|
|
704 |
search_text_fields = cgi['search-text-fields'] or [] |
search_text_fields = cgi['search-text-fields'] or [] |
705 |
|
|
706 |
begin |
mod = Module.new |
707 |
db.lock(project) |
|
708 |
|
db.transaction() do |
|
mod = Module.new |
|
709 |
url = @config.url |
url = @config.url |
710 |
selection_fields = db.selection_fields(project) |
selection_fields = db.selection_fields(project) |
711 |
text_fields = db.text_fields(project) |
text_fields = db.text_fields(project) |
754 |
@@offset = offset |
@@offset = offset |
755 |
@@params = cgi.params |
@@params = cgi.params |
756 |
end |
end |
|
compile('search.rhtml', mod) |
|
|
ensure |
|
|
db.unlock() |
|
757 |
end |
end |
758 |
|
|
759 |
|
compile('search.rhtml', mod) |
760 |
end |
end |
761 |
|
|
762 |
# Submit a bug. |
# Submit a bug. |
780 |
attachment.read) |
attachment.read) |
781 |
end |
end |
782 |
|
|
783 |
begin |
mod = Module.new |
784 |
db.lock(project, false) |
|
785 |
|
db.transaction() do |
786 |
fields = {} |
fields = {} |
787 |
selection_fields = db.selection_fields(project) |
selection_fields = db.selection_fields(project) |
788 |
text_fields = db.text_fields(project) |
text_fields = db.text_fields(project) |
841 |
send_bug(project, db.bug(project, bug_id), |
send_bug(project, db.bug(project, bug_id), |
842 |
selection_fields, text_fields, *lists) |
selection_fields, text_fields, *lists) |
843 |
|
|
|
mod = Module.new |
|
844 |
url = @config.url |
url = @config.url |
845 |
mod.module_eval do |
mod.module_eval do |
846 |
@@url = url |
@@url = url |
847 |
@@project = project |
@@project = project |
848 |
@@to_addrs = lists |
@@to_addrs = lists |
849 |
end |
end |
|
compile('submit-success.rhtml', mod) |
|
|
ensure |
|
|
db.unlock() |
|
850 |
end |
end |
851 |
|
|
852 |
|
compile('submit-success.rhtml', mod) |
853 |
end |
end |
854 |
|
|
855 |
def cgi_send(cgi, db) |
def cgi_send(cgi, db) |
857 |
get_params(cgi.params, |
get_params(cgi.params, |
858 |
['project', BugCommunicator::PROJECT_RE], |
['project', BugCommunicator::PROJECT_RE], |
859 |
['address'], |
['address'], |
860 |
['bug_id', /\A[1-9][0-9]+\z/, nil, false], |
['bug_id', /\A[0-9]+\z/, nil, false], |
861 |
['followup_id', /\A[1-9][0-9]+\z/, nil, false]) |
['followup_id', /\A[0-9]+\z/, nil, false]) |
862 |
|
|
863 |
if RMail::Address.new(address).address.nil? |
if RMail::Address.new(address).address.nil? |
864 |
raise MalformedRequestError, "invalid address `#{address}'" |
raise MalformedRequestError, "invalid address `#{address}'" |
873 |
"both bug_id and followup_id are specified" |
"both bug_id and followup_id are specified" |
874 |
end |
end |
875 |
|
|
876 |
begin |
mod = Module.new |
877 |
db.lock(project) |
|
878 |
|
db.transaction() do |
879 |
if bug_id |
if bug_id |
880 |
bug = db.bug(project, bug_id.to_i) |
bug = db.bug(project, bug_id.to_i) |
881 |
send_bug(project, bug, |
send_bug(project, bug, |
885 |
followup = db.followup(project, followup_id.to_i) |
followup = db.followup(project, followup_id.to_i) |
886 |
send_followup(project, followup, address) |
send_followup(project, followup, address) |
887 |
end |
end |
888 |
|
|
|
mod = Module.new |
|
889 |
url = @config.url |
url = @config.url |
890 |
mod.module_eval do |
mod.module_eval do |
891 |
@@url = url |
@@url = url |
892 |
@@project = project |
@@project = project |
893 |
@@to_addr = address |
@@to_addr = address |
894 |
end |
end |
|
compile('send-success.rhtml', mod) |
|
|
ensure |
|
|
db.unlock() |
|
895 |
end |
end |
896 |
|
|
897 |
|
compile('send-success.rhtml', mod) |
898 |
end |
end |
899 |
|
|
900 |
def cgi_commit(cgi, db) |
def cgi_commit(cgi, db) |
929 |
raise MalformedRequestError, "invalid address `#{address}'" |
raise MalformedRequestError, "invalid address `#{address}'" |
930 |
end |
end |
931 |
|
|
932 |
begin |
mod = Module.new |
933 |
db.lock(project, false) |
|
934 |
|
db.transaction() do |
935 |
actions = [] |
actions = [] |
936 |
|
|
937 |
if db.admins(project) != admins |
if db.admins(project) != admins |
1139 |
end |
end |
1140 |
send_confirmation(cid, action, *to_addrs) |
send_confirmation(cid, action, *to_addrs) |
1141 |
|
|
|
mod = Module.new |
|
1142 |
url = @config.url |
url = @config.url |
1143 |
mod.module_eval do |
mod.module_eval do |
1144 |
@@url = url |
@@url = url |
1145 |
@@project = project |
@@project = project |
1146 |
@@to_addrs = to_addrs |
@@to_addrs = to_addrs |
1147 |
end |
end |
|
compile('commit-success.rhtml', mod) |
|
|
ensure |
|
|
db.close() |
|
1148 |
end |
end |
1149 |
|
|
1150 |
|
compile('commit-success.rhtml', mod) |
1151 |
end |
end |
1152 |
|
|
1153 |
def cgi_get_attachment(cgi, db) |
def cgi_get_attachment(cgi, db) |
1154 |
project, bug_id = get_params(cgi.params, |
project, bug_id = get_params(cgi.params, |
1155 |
['project', BugCommunicator::PROJECT_RE], |
['project', BugCommunicator::PROJECT_RE], |
1156 |
['bug_id', /\A[1-9][0-9]+\z/]) |
['bug_id', /\A[0-9]+\z/]) |
1157 |
|
|
1158 |
begin |
db.transaction() do |
|
db.lock(project) |
|
1159 |
bug = db.bug(project, bug_id.to_i) |
bug = db.bug(project, bug_id.to_i) |
1160 |
unless bug.has_attachment? |
unless bug.has_attachment? |
1161 |
raise MalformedRequestError, "bug `#{bug_id}' has no attachment" |
raise MalformedRequestError, "bug `#{bug_id}' has no attachment" |
1164 |
"Content-Type: #{attachment.content_type}\r\n" + |
"Content-Type: #{attachment.content_type}\r\n" + |
1165 |
"Content-Length: #{attachment.size}\r\n\r\n" + |
"Content-Length: #{attachment.size}\r\n\r\n" + |
1166 |
attachment.contents |
attachment.contents |
|
ensure |
|
|
db.unlock() |
|
1167 |
end |
end |
1168 |
end |
end |
1169 |
|
|