lib/ezmlm/list.rb
author Mahlon E. Smith <mahlon@laika.com>
Mon, 06 Feb 2017 11:54:16 -0800
changeset 14 cba9fb39bcdb
parent 13 a03c08c289e9
child 15 a38e6916504c
permissions -rw-r--r--
Checkpoint commit. - Add the majority of the list behavioral knobs. - Add some quick helpers that can make list changes safely (write, unlink, touch) - Fix tests.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     1
#!/usr/bin/ruby
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
     2
# vim: set nosta noet ts=4 sw=4:
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     3
#
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
     4
# A Ruby interface to a single Ezmlm-idx mailing list directory.
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     5
#
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     6
# == Version
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     7
#
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     8
#  $Id$
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     9
#
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    10
#---
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    11
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    12
require 'pathname'
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    13
require 'etc'
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    14
require 'ezmlm'
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    15
require 'mail'
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    16
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    17
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    18
### A Ruby interface to an ezmlm-idx mailing list directory
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    19
###
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    20
class Ezmlm::List
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    21
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    22
	# Quick address space detection, to (hopefully)
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    23
	# match the overflow size on this machine.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    24
	#
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    25
	ADDRESS_SPACE = case [ 'i' ].pack( 'p' ).size
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    26
					when 4
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    27
						32
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    28
					when 8
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    29
						64
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    30
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    31
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    32
	# Valid subdirectories/sections for subscriptions.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    33
	SUBSCRIPTION_DIRS = %w[ deny mod digest allow ]
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    34
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    35
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    36
	### Create a new Ezmlm::List object for the specified +listdir+, which should be
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    37
	### an ezmlm-idx mailing list directory.
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    38
	###
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    39
	def initialize( listdir )
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    40
		listdir = Pathname.new( listdir ) unless listdir.is_a?( Pathname )
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    41
		@listdir = listdir
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    42
	end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    43
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    44
	# The Pathname object for the list directory
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    45
	attr_reader :listdir
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    46
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    47
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    48
	### Return the configured name of the list (without the host)
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    49
	###
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    50
	def name
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    51
		@name = self.read( 'outlocal' ) unless @name
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    52
		return @name
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    53
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    54
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    55
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    56
	### Return the configured host of the list
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    57
	###
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    58
	def host
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    59
		@host = self.read( 'outhost' ) unless @host
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    60
		return @host
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    61
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    62
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    63
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    64
	### Return the configured address of the list (in list@host form)
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    65
	###
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    66
	def address
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    67
		return "%s@%s" % [ self.name, self.host ]
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    68
	end
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    69
	alias_method :fullname, :address
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    70
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    71
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    72
	### Return the email address of the list's owner.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    73
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    74
	def owner
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    75
		owner = self.read( 'owner' )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    76
		return owner =~ /@/ ? owner : nil
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    77
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    78
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    79
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    80
	### Returns +true+ if +address+ is a subscriber to this list.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    81
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    82
	def include?( addr, section: nil )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    83
		addr.downcase!
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    84
		file = self.subscription_dir( section ) + self.hashchar( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    85
		return false unless file.exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    86
		return file.read.scan( /T([^\0]+)\0/ ).flatten.include?( addr )
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    87
	end
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    88
	alias_method :is_subscriber?, :include?
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    89
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    90
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    91
	### Fetch a sorted Array of the email addresses for all of the list's
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    92
	### subscribers.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    93
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    94
	def subscribers
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    95
		return self.read_subscriber_dir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    96
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    97
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    98
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    99
	### Subscribe +addr+ to the list within +section+.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   100
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   101
	def subscribe( *addr, section: nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   102
		addr.each do |address|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   103
			next unless address.index( '@' )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   104
			address.downcase!
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   105
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   106
			file = self.subscription_dir( section ) + self.hashchar( address )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   107
			self.with_safety do
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   108
				if file.exist?
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   109
					addresses = file.read.scan( /T([^\0]+)\0/ ).flatten
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   110
					addresses << address
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   111
					file.open( 'w' ) do |f|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   112
						f.print addresses.uniq.sort.map{|a| "T#{a}\0" }.join
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   113
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   114
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   115
				else
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   116
					file.open( 'w' ) do |f|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   117
						f.print "T%s\0" % [ address ]
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   118
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   119
				end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   120
			end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   121
		end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   122
	end
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   123
	alias_method :add_subscriber, :subscribe
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   124
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   125
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   126
	### Unsubscribe +addr+ from the list within +section+.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   127
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   128
	def unsubscribe( *addr, section: nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   129
		addr.each do |address|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   130
			address.downcase!
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   131
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   132
			file = self.subscription_dir( section ) + self.hashchar( address )
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   133
			self.with_safety do
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   134
				next unless file.exist?
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   135
				addresses = file.read.scan( /T([^\0]+)\0/ ).flatten
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   136
				addresses = addresses - [ address ]
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   137
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   138
				if addresses.empty?
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   139
					file.unlink
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   140
				else
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   141
					file.open( 'w' ) do |f|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   142
						f.print addresses.uniq.sort.map{|a| "T#{a}\0" }.join
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   143
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   144
				end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   145
			end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   146
		end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   147
	end
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   148
	alias_method :remove_subscriber, :unsubscribe
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   149
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   150
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   151
	### Returns an Array of email addresses of people responsible for
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   152
	### moderating subscription of a closed list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   153
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   154
	def moderators
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   155
		return self.read_subscriber_dir( 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   156
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   157
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   158
	### Returns +true+ if +address+ is a moderator.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   159
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   160
	def is_moderator?( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   161
		return self.include?( addr, section: 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   162
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   163
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   164
	### Subscribe +addr+ to the list as a Moderator.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   165
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   166
	def add_moderator( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   167
		return self.subscribe( *addr, section: 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   168
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   169
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   170
	### Remove +addr+ from the list as a Moderator.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   171
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   172
	def remove_moderator( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   173
		return self.unsubscribe( *addr, section: 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   174
	end
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   175
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   176
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   177
	### Returns an Array of email addresses denied access
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   178
	### to the list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   179
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   180
	def blacklisted
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   181
		return self.read_subscriber_dir( 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   182
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   183
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   184
	### Returns +true+ if +address+ is disallowed from participating.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   185
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   186
	def is_blacklisted?( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   187
		return self.include?( addr, section: 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   188
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   189
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   190
	### Blacklist +addr+ from the list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   191
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   192
	def add_blacklisted( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   193
		return self.subscribe( *addr, section: 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   194
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   195
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   196
	### Remove +addr+ from the blacklist.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   197
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   198
	def remove_blacklisted( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   199
		return self.unsubscribe( *addr, section: 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   200
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   201
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   202
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   203
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   204
	### Returns an Array of email addresses that act like
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   205
	### regular subscribers for user-post only lists.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   206
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   207
	def allowed
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   208
		return self.read_subscriber_dir( 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   209
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   210
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   211
	### Returns +true+ if +address+ is given the same benefits as a
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   212
	### regular subscriber for user-post only lists.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   213
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   214
	def is_allowed?( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   215
		return self.include?( addr, section: 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   216
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   217
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   218
	### Add +addr+ to allow posting to user-post only lists,
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   219
	### when +addr+ isn't a subscriber.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   220
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   221
	def add_allowed( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   222
		return self.subscribe( *addr, section: 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   223
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   224
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   225
	### Remove +addr+ from the allowed list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   226
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   227
	def remove_allowed( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   228
		return self.unsubscribe( *addr, section: 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   229
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   230
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   231
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   232
	### Returns +true+ if message threading is enabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   233
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   234
	def threaded?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   235
		return ( self.listdir + 'threaded' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   236
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   237
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   238
	### Disable or enable message threading.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   239
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   240
	### This automatically builds message indexes and thread
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   241
	### information on an incoming message.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   242
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   243
	def threaded=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   244
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   245
			self.touch( 'threaded' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   246
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   247
			self.unlink( 'threaded' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   248
		end
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   249
	end
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   250
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   251
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   252
	### Returns +true+ if the list is configured to respond
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   253
	### to remote mangement requests.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   254
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   255
	def public?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   256
		return ( self.listdir + 'public' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   257
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   258
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   259
	### Disable or enable remote management requests.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   260
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   261
	def public=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   262
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   263
			self.touch( 'public' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   264
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   265
			self.unlink( 'public' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   266
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   267
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   268
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   269
	### Returns +true+ if the list is not configured to respond
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   270
	### to remote mangement requests.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   271
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   272
	def private?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   273
		return ! self.public?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   274
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   275
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   276
	### Disable or enable remote management requests.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   277
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   278
	def private=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   279
		self.public = ! enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   280
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   281
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   282
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   283
	### Returns +true+ if the list supports remote administration
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   284
	### subscribe/unsubscribe requests from moderators.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   285
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   286
	def remote_subscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   287
		return ( self.listdir + 'remote' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   288
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   289
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   290
	### Disable or enable remote subscription requests.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   291
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   292
	def remote_subscriptions=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   293
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   294
			self.touch( 'remote' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   295
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   296
			self.unlink( 'remote' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   297
		end
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   298
	end
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
   299
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
   300
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   301
	### Returns +true+ if list subscription requests require moderator
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   302
	### approval.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   303
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   304
	def moderated_subscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   305
		return ( self.listdir + 'modsub' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   306
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   307
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   308
	### Disable or enable subscription moderation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   309
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   310
	def moderated_subscriptions=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   311
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   312
			self.touch( 'modsub' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   313
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   314
			self.unlink( 'modsub' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   315
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   316
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   317
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   318
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   319
	### Returns +true+ if message moderation is enabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   320
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   321
	def moderated?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   322
		return ( self.listdir + 'modpost' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   323
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   324
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   325
	### Disable or enable message moderation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   326
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   327
	### This has special meaning when combined with user_post_only setting.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   328
	### Lists act as unmoderated for subscribers, and posts from unknown
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   329
	### addresses go to moderation.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   330
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   331
	def moderated=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   332
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   333
			self.touch( 'modpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   334
			self.touch( 'noreturnposts' ) if self.user_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   335
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   336
			self.unlink( 'modpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   337
			self.unlink( 'noreturnposts' ) if self.user_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   338
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   339
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   340
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   341
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   342
	### Returns +true+ if posting is only allowed by moderators.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   343
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   344
	def moderator_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   345
		return ( self.listdir + 'modpostonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   346
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   347
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   348
	### Disable or enable moderation only posts.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   349
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   350
	def moderator_posts_only=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   351
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   352
			self.touch( 'modpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   353
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   354
			self.unlink( 'modpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   355
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   356
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   357
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   358
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   359
	### Returns +true+ if posting is only allowed by subscribers.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   360
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   361
	def user_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   362
		return ( self.listdir + 'subpostonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   363
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   364
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   365
	### Disable or enable user only posts.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   366
	### This is easily defeated, moderated lists are preferred.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   367
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   368
	### This has special meaning for moderated lists.  Lists act as
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   369
	### unmoderated for subscribers, and posts from unknown addresses
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   370
	### go to moderation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   371
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   372
	def user_posts_only=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   373
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   374
			self.touch( 'subpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   375
			self.touch( 'noreturnposts' )if self.moderated?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   376
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   377
			self.unlink( 'subpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   378
			self.unlink( 'noreturnposts' ) if self.moderated?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   379
		end
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   380
	end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   381
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   382
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   383
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   384
	### Returns +true+ if message archival is enabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   385
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   386
	def archived?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   387
		return ( self.listdir + 'archived' ).exist? || ( self.listdir + 'indexed' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   388
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   389
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   390
	### Disable or enable message archiving (and indexing.)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   391
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   392
	def archive=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   393
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   394
			self.touch( 'archived' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   395
			self.touch( 'indexed' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   396
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   397
			self.unlink( 'archived' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   398
			self.unlink( 'indexed' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   399
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   400
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   401
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   402
	### Returns +true+ if the message archive is accessible only to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   403
	### moderators.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   404
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   405
	def private_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   406
		return ( self.listdir + 'modgetonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   407
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   408
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   409
	### Disable or enable private access to the archive.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   410
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   411
	def private_archive=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   412
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   413
			self.touch( 'modgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   414
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   415
			self.unlink( 'modgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   416
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   417
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   418
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   419
	### Returns +true+ if the message archive is accessible to anyone.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   420
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   421
	def public_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   422
		return ! self.private_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   423
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   424
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   425
	### Returns +true+ if the message archive is accessible only to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   426
	### list subscribers.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   427
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   428
	def guarded_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   429
		return ( self.listdir + 'subgetonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   430
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   431
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   432
	### Disable or enable loimited access to the archive.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   433
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   434
	def guarded_archive=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   435
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   436
			self.touch( 'subgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   437
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   438
			self.unlink( 'subgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   439
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   440
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   441
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   442
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   443
	### Returns +true+ if message digests are enabled.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   444
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   445
	def digested?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   446
		return ( self.listdir + 'digested' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   447
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   448
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   449
	### Disable or enable message digesting.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   450
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   451
	def digest=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   452
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   453
			self.touch( 'digested' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   454
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   455
			self.unlink( 'digested' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   456
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   457
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   458
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   459
	### If the list is digestable, trigger the digest after this amount
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   460
	### of message body since the latest digest, in kbytes.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   461
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   462
	### See: ezmlm-tstdig(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   463
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   464
	def digest_kbytesize
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   465
		size = self.read( 'digsize' ).to_i
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   466
		return size.zero? ? 64 : size
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   467
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   468
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   469
	### If the list is digestable, trigger the digest after this amount
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   470
	### of message body since the latest digest, in kbytes.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   471
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   472
	### See: ezmlm-tstdig(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   473
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   474
	def digest_kbytesize=( size=64 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   475
		self.write( 'digsize' ) {|f| f.puts size.to_i }
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   476
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   477
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   478
	### If the list is digestable, trigger the digest after this many
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   479
	### messages have accumulated since the latest digest.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   480
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   481
	### See: ezmlm-tstdig(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   482
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   483
	def digest_count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   484
		count = self.read( 'digcount' ).to_i
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   485
		return count.zero? ? 30 : count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   486
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   487
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   488
	### If the list is digestable, trigger the digest after this many
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   489
	### messages have accumulated since the latest digest.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   490
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   491
	### See: ezmlm-tstdig(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   492
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   493
	def digest_count=( count=30 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   494
		self.write( 'digcount' ) {|f| f.puts count.to_i }
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   495
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   496
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   497
	### If the list is digestable, trigger the digest after this much
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   498
	### time has passed since the last digest, in hours.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   499
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   500
	### See: ezmlm-tstdig(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   501
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   502
	def digest_timeout
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   503
		hours = self.read( 'digtime' ).to_i
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   504
		return hours.zero? ? 48 : hours
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   505
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   506
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   507
	### If the list is digestable, trigger the digest after this much
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   508
	### time has passed since the last digest, in hours.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   509
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   510
	### See: ezmlm-tstdig(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   511
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   512
	def digest_timeout=( hours=48 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   513
		self.write( 'digtime' ) {|f| f.puts hours.to_i }
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   514
	end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   515
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   516
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   517
	### Returns +true+ if the list requires subscriptions to be
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   518
	### confirmed.  AKA "help" mode if disabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   519
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   520
	def confirm_subscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   521
		return ! ( self.listdir + 'nosubconfirm' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   522
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   523
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   524
	### Disable or enable subscription confirmation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   525
	### AKA "help" mode if disabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   526
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   527
	def confirm_subscriptions=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   528
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   529
			self.unlink( 'nosubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   530
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   531
			self.touch( 'nosubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   532
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   533
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   534
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   535
	### Returns +true+ if the list requires unsubscriptions to be
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   536
	### confirmed.  AKA "jump" mode.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   537
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   538
	def confirm_unsubscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   539
		return ! ( self.listdir + 'nounsubconfirm' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   540
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   541
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   542
	### Disable or enable unsubscription confirmation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   543
	### AKA "jump" mode.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   544
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   545
	def confirm_unsubscriptions=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   546
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   547
			self.unlink( 'nounsubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   548
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   549
			self.touch( 'nounsubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   550
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   551
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   552
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   553
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   554
	### Returns +true+ if the list requires regular message postings
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   555
	### to be confirmed by the original sender.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   556
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   557
	def confirm_postings?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   558
		return ( self.listdir + 'confirmpost' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   559
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   560
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   561
	### Disable or enable message confirmation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   562
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   563
	def confirm_postings=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   564
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   565
			self.touch( 'confirmpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   566
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   567
			self.unlink( 'confirmpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   568
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   569
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   570
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   571
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   572
	### Returns +true+ if the list allows moderators to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   573
	### fetch a subscriber list remotely.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   574
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   575
	def allow_remote_listing?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   576
		return ( self.listdir + 'modcanlist' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   577
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   578
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   579
	### Disable or enable the ability for moderators to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   580
	### remotely fetch a subscriber list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   581
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   582
	def allow_remote_listing=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   583
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   584
			self.touch( 'modcanlist' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   585
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   586
			self.unlink( 'modcanlist' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   587
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   588
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   589
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   590
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   591
	### Returns +true+ if the list automatically manages
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   592
	### bouncing subscriber addresses.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   593
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   594
	def bounce_warnings?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   595
		return ! ( self.listdir + 'nowarn' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   596
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   597
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   598
	### Disable or enable automatic bounce probes and warnings.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   599
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   600
	def bounce_warnings=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   601
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   602
			self.unlink( 'nowarn' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   603
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   604
			self.touch( 'nowarn' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   605
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   606
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   607
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   608
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   609
	### Return the maximum message size, in bytes.  Messages larger than
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   610
	### this size will be rejected.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   611
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   612
	### See: ezmlm-reject(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   613
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   614
	def maximum_message_size
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   615
		size = self.read( 'msgsize' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   616
		return size ? size.split( ':' ).first.to_i : 0
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   617
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   618
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   619
	### Set the maximum message size, in bytes.  Messages larger than
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   620
	### this size will be rejected.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   621
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   622
	### See: ezmlm-reject(1)
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   623
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   624
	def maximum_message_size=( size=307200 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   625
		if size.to_i.zero?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   626
			self.unlink( 'msgsize' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   627
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   628
			self.write( 'msgsize' ) {|f| f.puts "#{size.to_i}:0" }
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   629
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   630
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   631
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   632
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   633
	### Return the number of messages in the list archive.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   634
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   635
	def message_count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   636
		count = self.read( 'archnum' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   637
		return count ? Integer( count ) : 0
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   638
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   639
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   640
	### Returns the last message to the list as a Mail::Message, if
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   641
	### archiving was enabled.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   642
	###
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   643
	def last_post
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   644
		num = self.message_count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   645
		return if num.zero?
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   646
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   647
		hashdir = num / 100
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   648
		message = "%02d" % [ num % 100 ]
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   649
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   650
		post = self.listdir + 'archive' + hashdir.to_s + message.to_s
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   651
		return unless post.exist?
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   652
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   653
		return Mail.read( post.to_s )
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   654
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   655
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   656
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   657
	#########
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   658
	protected
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   659
	#########
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   660
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   661
	### Hash an email address, using the ezmlm algorithm for
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   662
	### fast user lookups.  Returns the hashed integer.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   663
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   664
	### Older ezmlm didn't lowercase addresses, anything within the last
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   665
	### decade did.  We're not going to worry about compatibility there.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   666
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   667
	### See: subhash.c in the ezmlm source.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   668
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   669
	def subhash( addr )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   670
		h = 5381
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   671
		over = 2 ** ADDRESS_SPACE
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   672
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   673
		addr = 'T' + addr
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   674
		addr.each_char do |c|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   675
			h = ( h + ( h << 5 ) ) ^ c.ord
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   676
			h = h % over if h > over # emulate integer overflow
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   677
		end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   678
		return h % 53
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   679
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   680
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   681
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   682
	### Given an email address, return the ascii character.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   683
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   684
	def hashchar( addr )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   685
		return ( self.subhash(addr) + 64 ).chr
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   686
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   687
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   688
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   689
	### Just return the contents of the provided +file+, rooted
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   690
	### in the list directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   691
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   692
	def read( file )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   693
		file = self.listdir + file unless file.is_a?( Pathname )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   694
		return file.read.chomp
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   695
	rescue
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   696
		nil
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   697
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   698
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   699
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   700
	### Overwrite +file+ safely, yielding the open filehandle to the
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   701
	### block.  Set the new file to correct ownership and permissions.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   702
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   703
	def write( file, &block )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   704
		file = self.listdir + file unless file.is_a?( Pathname )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   705
		self.with_safety do
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   706
			file.open( 'w' ) do |f|
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   707
				yield( f )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   708
			end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   709
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   710
			stat = self.listdir.stat
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   711
			file.chown( stat.uid, stat.gid )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   712
			file.chmod( 0600 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   713
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   714
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   715
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   716
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   717
	### Simply create an empty file, safely.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   718
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   719
	def touch( file )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   720
		self.write( file ) {}
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   721
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   722
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   723
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   724
	### Delete +file+ safely.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   725
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   726
	def unlink( file )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   727
		file = self.listdir + file unless file.is_a?( Pathname )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   728
		return unless file.exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   729
		self.with_safety do
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   730
			file.unlink
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   731
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   732
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   733
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   734
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   735
	### Return a Pathname to a subscription directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   736
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   737
	def subscription_dir( section=nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   738
		if section
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   739
			unless SUBSCRIPTION_DIRS.include?( section )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   740
				raise "Invalid subscription dir: %s, must be one of: %s" % [
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   741
					section,
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   742
					SUBSCRIPTION_DIRS.join( ', ' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   743
				]
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   744
			end
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   745
			return self.listdir + section + 'subscribers'
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   746
		else
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   747
			return self.listdir + 'subscribers'
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   748
		end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   749
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   750
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   751
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   752
	### Read the hashed subscriber email addresses from the specified
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   753
	### +directory+ and return them in an Array.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   754
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   755
	def read_subscriber_dir( section=nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   756
		directory = self.subscription_dir( section )
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   757
		rval = []
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   758
		Pathname.glob( directory + '*' ) do |hashfile|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   759
			rval.push( hashfile.read.scan(/T([^\0]+)\0/) )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   760
		end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   761
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   762
		return rval.flatten.sort
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   763
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   764
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   765
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   766
	### Return a Pathname object for the list owner's home directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   767
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   768
	def homedir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   769
		user = Etc.getpwuid( self.listdir.stat.uid )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   770
		return Pathname( user.dir )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   771
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   772
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   773
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   774
	### Safely make modifications to a file within a list directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   775
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   776
	### Mail can come in at any time.  Make changes within a list
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   777
	### atomic -- if an incoming message hits when a sticky
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   778
	### is set, it is deferred to the Qmail queue.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   779
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   780
	###   - Set sticky bit on the list directory owner's homedir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   781
	###   - Make changes with the block
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   782
	###   - Unset sticky (just back to what it was previously)
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   783
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   784
	### All writes should be wrapped in this method.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   785
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   786
	def with_safety( &block )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   787
		home = self.homedir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   788
		mode = home.stat.mode
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   789
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   790
		home.chmod( mode | 01000 ) # enable sticky
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   791
		yield
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   792
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   793
	ensure
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   794
		home.chmod( mode )
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   795
	end
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
   796
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   797
end # class Ezmlm::List
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   798