lib/ezmlm/list.rb
author Mahlon E. Smith <mahlon@laika.com>
Tue, 16 May 2017 13:58:52 -0700
changeset 18 9aaac749fd9f
parent 17 23c7f5c8ee39
child 20 9d59d30685cb
permissions -rw-r--r--
Bump version.
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:
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     3
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     4
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     5
# 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
     6
#
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     7
#    list = Ezmlm::List.new( '/path/to/listdir' )
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     8
#
1
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
# == Version
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
#  $Id$
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    13
#
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    14
#---
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    15
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    16
require 'pathname'
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    17
require 'time'
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    18
require 'etc'
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    19
require 'ezmlm' unless defined?( Ezmlm )
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    20
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    21
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    22
### 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
    23
###
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    24
class Ezmlm::List
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    25
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    26
	# Valid subdirectories/sections for subscriptions.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    27
	SUBSCRIPTION_DIRS = %w[ deny mod digest allow ]
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    28
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    29
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    30
	### 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
    31
	### 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
    32
	###
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    33
	def initialize( listdir )
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    34
		listdir = Pathname.new( listdir ) unless listdir.is_a?( Pathname )
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
    35
		unless listdir.directory? && ( listdir + 'mailinglist' ).exist?
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
    36
			raise ArgumentError, "%p doesn't appear to be an ezmlm-idx list." % [ listdir.to_s ]
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
    37
		end
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    38
		@listdir = listdir
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    39
	end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    40
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    41
	# The Pathname object for the list directory
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
    42
	attr_reader :listdir
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
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    45
	### Return the configured name of the list (without the host)
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    46
	###
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    47
	def name
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    48
		@name = self.read( 'outlocal' ) unless @name
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    49
		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
    50
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    51
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    52
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    53
	### Return the configured host of the list
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
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
	def host
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    56
		@host = self.read( 'outhost' ) unless @host
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    57
		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
    58
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    59
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    60
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    61
	### 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
    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
	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
    64
		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
    65
	end
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    66
	alias_method :fullname, :address
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
    67
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
    68
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    69
	### Return the email address of the list's owner.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    70
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    71
	def owner
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    72
		owner = self.read( 'owner' )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    73
		return owner =~ /@/ ? owner : nil
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    74
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    75
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    76
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    77
	### Returns +true+ if +address+ is a subscriber to this list.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    78
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    79
	def include?( addr, section: nil )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    80
		addr.downcase!
16
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
    81
		file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( addr )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    82
		return false unless file.exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    83
		return file.read.scan( /T([^\0]+)\0/ ).flatten.include?( addr )
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    84
	end
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
    85
	alias_method :is_subscriber?, :include?
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    86
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    87
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    88
	### 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
    89
	### subscribers.
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
	def subscribers
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    92
		return self.read_subscriber_dir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    93
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    94
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    95
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    96
	### Subscribe +addr+ to the list within +section+.
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
	def subscribe( *addr, section: nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
    99
		addr.each do |address|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   100
			next unless address.index( '@' )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   101
			address.downcase!
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   102
16
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
   103
			file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( address )
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   104
			self.with_safety do
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   105
				if file.exist?
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   106
					addresses = file.read.scan( /T([^\0]+)\0/ ).flatten
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   107
					addresses << address
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   108
					file.open( 'w' ) do |f|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   109
						f.print addresses.uniq.sort.map{|a| "T#{a}\0" }.join
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   110
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   111
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   112
				else
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   113
					file.open( 'w' ) do |f|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   114
						f.print "T%s\0" % [ address ]
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   115
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   116
				end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   117
			end
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
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   120
	alias_method :add_subscriber, :subscribe
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   121
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   122
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   123
	### Unsubscribe +addr+ from the list within +section+.
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
	def unsubscribe( *addr, section: nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   126
		addr.each do |address|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   127
			address.downcase!
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   128
16
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
   129
			file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( address )
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   130
			self.with_safety do
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   131
				next unless file.exist?
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   132
				addresses = file.read.scan( /T([^\0]+)\0/ ).flatten
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   133
				addresses = addresses - [ address ]
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   134
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   135
				if addresses.empty?
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   136
					file.unlink
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   137
				else
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   138
					file.open( 'w' ) do |f|
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   139
						f.print addresses.uniq.sort.map{|a| "T#{a}\0" }.join
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   140
					end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   141
				end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   142
			end
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
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   145
	alias_method :remove_subscriber, :unsubscribe
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   146
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   147
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   148
	### Returns an Array of email addresses of people responsible for
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   149
	### moderating subscription of a closed list.
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
	def moderators
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   152
		return self.read_subscriber_dir( 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   153
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   154
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   155
	### Returns +true+ if +address+ is a moderator.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   156
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   157
	def is_moderator?( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   158
		return self.include?( addr, section: 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   159
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   160
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   161
	### Subscribe +addr+ to the list as a Moderator.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   162
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   163
	def add_moderator( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   164
		return self.subscribe( *addr, section: 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   165
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   166
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   167
	### Remove +addr+ from the list as a Moderator.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   168
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   169
	def remove_moderator( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   170
		return self.unsubscribe( *addr, section: 'mod' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   171
	end
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   172
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   173
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   174
	### Returns an Array of email addresses denied access
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   175
	### to the list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   176
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   177
	def blacklisted
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   178
		return self.read_subscriber_dir( 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   179
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   180
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   181
	### Returns +true+ if +address+ is disallowed from participating.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   182
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   183
	def is_blacklisted?( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   184
		return self.include?( addr, section: 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   185
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   186
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   187
	### Blacklist +addr+ from the list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   188
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   189
	def add_blacklisted( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   190
		return self.subscribe( *addr, section: 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   191
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   192
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   193
	### Remove +addr+ from the blacklist.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   194
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   195
	def remove_blacklisted( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   196
		return self.unsubscribe( *addr, section: 'deny' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   197
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   198
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   199
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   200
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   201
	### Returns an Array of email addresses that act like
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   202
	### regular subscribers for user-post only lists.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   203
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   204
	def allowed
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   205
		return self.read_subscriber_dir( 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   206
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   207
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   208
	### Returns +true+ if +address+ is given the same benefits as a
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   209
	### regular subscriber for user-post only lists.
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
	def is_allowed?( addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   212
		return self.include?( addr, section: 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   213
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   214
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   215
	### Add +addr+ to allow posting to user-post only lists,
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   216
	### when +addr+ isn't a subscriber.
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
	def add_allowed( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   219
		return self.subscribe( *addr, section: 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   220
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   221
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   222
	### Remove +addr+ from the allowed list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   223
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   224
	def remove_allowed( *addr )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   225
		return self.unsubscribe( *addr, section: 'allow' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   226
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   227
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   228
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   229
	### Returns +true+ if the list is configured to respond
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   230
	### to remote management requests.
14
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
	def public?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   233
		return ( self.listdir + 'public' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   234
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   235
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   236
	### Disable or enable remote management requests.
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
	def public=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   239
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   240
			self.touch( 'public' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   241
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   242
			self.unlink( 'public' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   243
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   244
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   245
	alias_method :public, :public=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   246
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   247
	### Returns +true+ if the list is not configured to respond
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   248
	### to remote management requests.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   249
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   250
	def private?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   251
		return ! self.public?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   252
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   253
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   254
	### Disable or enable remote management requests.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   255
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   256
	def private=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   257
		self.public = ! enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   258
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   259
	alias_method :private, :private=
14
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
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   262
	### Returns +true+ if the list supports remote administration
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   263
	### subscribe/unsubscribe requests from moderators.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   264
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   265
	def remote_subscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   266
		return ( self.listdir + 'remote' ).exist?
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
	### Disable or enable remote subscription requests.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   270
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   271
	def remote_subscriptions=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   272
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   273
			self.touch( 'remote' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   274
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   275
			self.unlink( 'remote' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   276
		end
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   277
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   278
	alias_method :remote_subscriptions, :remote_subscriptions=
5
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
   279
804e1c2b9a40 * Added rdoc-generation to the cruise task and the artifacts that get saved
Michael Granger <mgranger@laika.com>
parents: 4
diff changeset
   280
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   281
	### Returns +true+ if list subscription requests require moderator
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   282
	### approval.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   283
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   284
	def moderated_subscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   285
		return ( self.listdir + 'modsub' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   286
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   287
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   288
	### Disable or enable subscription moderation.
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
	def moderated_subscriptions=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   291
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   292
			self.touch( 'modsub' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   293
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   294
			self.unlink( 'modsub' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   295
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   296
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   297
	alias_method :moderated_subscriptions, :moderated_subscriptions=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   298
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   299
	### Returns +true+ if message moderation is enabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   300
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   301
	def moderated?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   302
		return ( self.listdir + 'modpost' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   303
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   304
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   305
	### Disable or enable message moderation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   306
	###
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   307
	### This has special meaning when combined with user_posts_only setting.
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   308
	### Lists act as unmoderated for subscribers, and posts from unknown
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   309
	### addresses go to moderation.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   310
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   311
	def moderated=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   312
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   313
			self.touch( 'modpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   314
			self.touch( 'noreturnposts' ) if self.user_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   315
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   316
			self.unlink( 'modpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   317
			self.unlink( 'noreturnposts' ) if self.user_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   318
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   319
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   320
	alias_method :moderated, :moderated=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   321
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   322
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   323
	### Returns +true+ if posting is only allowed by moderators.
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
	def moderator_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   326
		return ( self.listdir + 'modpostonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   327
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   328
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   329
	### Disable or enable moderation only posts.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   330
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   331
	def moderator_posts_only=( 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( 'modpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   334
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   335
			self.unlink( 'modpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   336
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   337
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   338
	alias_method :moderator_posts_only, :moderator_posts_only=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   339
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
	### Returns +true+ if posting is only allowed by subscribers.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   342
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   343
	def user_posts_only?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   344
		return ( self.listdir + 'subpostonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   345
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   346
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   347
	### Disable or enable user only posts.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   348
	### This is easily defeated, moderated lists are preferred.
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
	### This has special meaning for moderated lists.  Lists act as
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   351
	### unmoderated for subscribers, and posts from unknown addresses
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   352
	### go to moderation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   353
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   354
	def user_posts_only=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   355
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   356
			self.touch( 'subpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   357
			self.touch( 'noreturnposts' )if self.moderated?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   358
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   359
			self.unlink( 'subpostonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   360
			self.unlink( 'noreturnposts' ) if self.moderated?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   361
		end
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   362
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   363
	alias_method :user_posts_only, :user_posts_only=
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   364
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   365
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   366
	### Returns +true+ if message archival is enabled.
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
	def archived?
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   369
		test = %w[ archived indexed threaded ].each_with_object( [] ) do |f, acc|
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   370
			acc << self.listdir + f
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   371
		end
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   372
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   373
		return test.all?( &:exist? )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   374
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   375
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   376
	### Disable or enable message archiving (and indexing/threading.)
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   377
	###
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   378
	def archived=( enable=true )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   379
		if enable
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   380
			self.touch( 'archived', 'indexed', 'threaded' )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   381
		else
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   382
			self.unlink( 'archived', 'indexed', 'threaded' )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   383
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   384
	end
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   385
	alias_method :archived, :archived=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   386
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   387
	### Returns +true+ if the message archive is accessible only to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   388
	### moderators.
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
	def private_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   391
		return ( self.listdir + 'modgetonly' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   392
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   393
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   394
	### Disable or enable private access to the archive.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   395
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   396
	def private_archive=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   397
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   398
			self.touch( 'modgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   399
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   400
			self.unlink( 'modgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   401
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   402
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   403
	alias_method :private_archive, :private_archive=
14
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
	### Returns +true+ if the message archive is accessible to anyone.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   406
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   407
	def public_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   408
		return ! self.private_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   409
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   410
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   411
	### Disable or enable private access to the archive.
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   412
	###
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   413
	def public_archive=( enable=true )
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   414
		self.private_archive = ! enable
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   415
	end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   416
	alias_method :public_archive, :public_archive=
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   417
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   418
	### Returns +true+ if the message archive is accessible only to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   419
	### list subscribers.
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 guarded_archive?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   422
		return ( self.listdir + 'subgetonly' ).exist?
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
	### Disable or enable loimited access to the archive.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   426
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   427
	def guarded_archive=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   428
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   429
			self.touch( 'subgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   430
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   431
			self.unlink( 'subgetonly' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   432
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   433
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   434
	alias_method :guarded_archive, :guarded_archive=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   435
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   436
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   437
	### Returns +true+ if message digests are enabled.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   438
	###
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   439
	def digested?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   440
		return ( self.listdir + 'digested' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   441
	end
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
	### Disable or enable message digesting.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   444
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   445
	def digest=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   446
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   447
			self.touch( 'digested' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   448
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   449
			self.unlink( 'digested' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   450
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   451
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   452
	alias_method :digest, :digest=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   453
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   454
	### If the list is digestable, trigger the digest after this amount
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   455
	### of message body since the latest digest, in kbytes.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   456
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   457
	### See: ezmlm-tstdig(1)
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
	def digest_kbytesize
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   460
		size = self.read( 'digsize' ).to_i
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   461
		return size.zero? ? 64 : size
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   462
	end
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
	### If the list is digestable, trigger the digest after this amount
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   465
	### of message body since the latest digest, in kbytes.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   466
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   467
	### See: ezmlm-tstdig(1)
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
	def digest_kbytesize=( size=64 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   470
		self.write( 'digsize' ) {|f| f.puts size.to_i }
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   471
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   472
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   473
	### If the list is digestable, trigger the digest after this many
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   474
	### messages have accumulated since the latest digest.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   475
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   476
	### See: ezmlm-tstdig(1)
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
	def digest_count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   479
		count = self.read( 'digcount' ).to_i
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   480
		return count.zero? ? 30 : count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   481
	end
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
	### If the list is digestable, trigger the digest after this many
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   484
	### messages have accumulated since the latest digest.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   485
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   486
	### See: ezmlm-tstdig(1)
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
	def digest_count=( count=30 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   489
		self.write( 'digcount' ) {|f| f.puts count.to_i }
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   490
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   491
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   492
	### If the list is digestable, trigger the digest after this much
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   493
	### time has passed since the last digest, in hours.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   494
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   495
	### See: ezmlm-tstdig(1)
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
	def digest_timeout
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   498
		hours = self.read( 'digtime' ).to_i
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   499
		return hours.zero? ? 48 : hours
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   500
	end
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
	### If the list is digestable, trigger the digest after this much
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   503
	### time has passed since the last digest, in hours.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   504
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   505
	### See: ezmlm-tstdig(1)
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
	def digest_timeout=( hours=48 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   508
		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
   509
	end
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   510
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   511
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   512
	### Returns +true+ if the list requires subscriptions to be
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   513
	### confirmed.  AKA "help" mode if disabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   514
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   515
	def confirm_subscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   516
		return ! ( self.listdir + 'nosubconfirm' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   517
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   518
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   519
	### Disable or enable subscription confirmation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   520
	### AKA "help" mode if disabled.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   521
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   522
	def confirm_subscriptions=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   523
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   524
			self.unlink( 'nosubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   525
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   526
			self.touch( 'nosubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   527
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   528
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   529
	alias_method :confirm_subscriptions, :confirm_subscriptions=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   530
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   531
	### Returns +true+ if the list requires unsubscriptions to be
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   532
	### confirmed.  AKA "jump" mode.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   533
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   534
	def confirm_unsubscriptions?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   535
		return ! ( self.listdir + 'nounsubconfirm' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   536
	end
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
	### Disable or enable unsubscription confirmation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   539
	### AKA "jump" mode.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   540
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   541
	def confirm_unsubscriptions=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   542
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   543
			self.unlink( 'nounsubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   544
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   545
			self.touch( 'nounsubconfirm' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   546
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   547
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   548
	alias_method :confirm_unsubscriptions, :confirm_unsubscriptions=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   549
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   550
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   551
	### Returns +true+ if the list requires regular message postings
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   552
	### to be confirmed by the original sender.
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
	def confirm_postings?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   555
		return ( self.listdir + 'confirmpost' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   556
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   557
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   558
	### Disable or enable message confirmation.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   559
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   560
	def confirm_postings=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   561
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   562
			self.touch( 'confirmpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   563
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   564
			self.unlink( 'confirmpost' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   565
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   566
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   567
	alias_method :confirm_postings, :confirm_postings=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   568
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   569
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   570
	### Returns +true+ if the list allows moderators to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   571
	### fetch a subscriber list remotely.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   572
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   573
	def allow_remote_listing?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   574
		return ( self.listdir + 'modcanlist' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   575
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   576
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   577
	### Disable or enable the ability for moderators to
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   578
	### remotely fetch a subscriber list.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   579
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   580
	def allow_remote_listing=( enable=false )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   581
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   582
			self.touch( 'modcanlist' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   583
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   584
			self.unlink( 'modcanlist' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   585
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   586
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   587
	alias_method :allow_remote_listing, :allow_remote_listing=
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   588
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
	### Returns +true+ if the list automatically manages
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   591
	### bouncing subscriber addresses.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   592
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   593
	def bounce_warnings?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   594
		return ! ( self.listdir + 'nowarn' ).exist?
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   595
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   596
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   597
	### Disable or enable automatic bounce probes and warnings.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   598
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   599
	def bounce_warnings=( enable=true )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   600
		if enable
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   601
			self.unlink( 'nowarn' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   602
		else
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   603
			self.touch( 'nowarn' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   604
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   605
	end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   606
	alias_method :bounce_warnings, :bounce_warnings=
14
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
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   620
	### this size will be rejected.  Defaults to 300kb.
14
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
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   633
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   634
	### Return the number of messages in the list archive.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   635
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   636
	def message_count
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   637
		count = self.read( 'archnum' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   638
		return count ? Integer( count ) : 0
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   639
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   640
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   641
	### Returns an individual message if archiving was enabled.
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   642
	###
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   643
	def message( message_id )
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   644
		raise "Message archive is empty." if self.message_count.zero?
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   645
		return Ezmlm::List::Message.new( self, message_id ) rescue nil
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   646
	end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   647
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   648
	### Lazy load each message ID as a Ezmlm::List::Message,
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   649
	### yielding it to the block.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   650
	###
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   651
	def each_message
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   652
		( 1 .. self.message_count ).each do |id|
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   653
			yield self.message( id )
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   654
		end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   655
	end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   656
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   657
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   658
	### Return a Thread object for the given +thread_id+.
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   659
	###
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   660
	def thread( thread_id )
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   661
		return Ezmlm::List::Thread.new( self, thread_id ) rescue nil
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   662
	end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   663
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   664
16
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
   665
	### Return an Author object for the given +author_id+, which
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
   666
	### could also be an email address.
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   667
	###
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   668
	def author( author_id )
16
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
   669
		author_id = Ezmlm::Hash.address(author_id) if author_id.index( '@' )
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   670
		return Ezmlm::List::Author.new( self, author_id ) rescue nil
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   671
	end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   672
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   673
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   674
	### Parse all thread indexes into a single array that can be used
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   675
	### as a lookup table.
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   676
	###
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   677
	### These are not expanded into objects, use #message, #thread,
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   678
	### and #author to do so.
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   679
	###
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   680
	def index
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   681
		raise "Archiving is not enabled." unless self.archived?
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   682
		archivedir = listdir + 'archive'
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   683
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   684
		idx = ( 0 .. self.message_count / 100 ).each_with_object( [] ) do |dir, acc|
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   685
			index = archivedir + dir.to_s + 'index'
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   686
			next unless index.exist?
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   687
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   688
			index.open( 'r', encoding: Encoding::ISO8859_1 ) do |fh|
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   689
				fh.each_line.lazy.slice_before( /^\d+:/ ).each do |message|
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   690
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   691
					match = message[0].match( /^(?<message_id>\d+): (?<thread_id>\w+)/ )
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   692
					next unless match
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   693
					thread_id  = match[ :thread_id ]
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   694
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   695
					match = message[1].match( /^(?<date>[^;]+);(?<author_id>\w+) / )
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   696
					next unless match
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   697
					author_id  = match[ :author_id ]
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   698
					date       = match[ :date ]
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   699
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   700
					metadata = {
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   701
						date:   Time.parse( date ),
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   702
						thread: thread_id,
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   703
						author: author_id
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   704
					}
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   705
					acc << metadata
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   706
				end
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   707
			end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   708
		end
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   709
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
   710
		return idx
4
8c4ae0797d5f Added more archive-related functions:
Michael Granger <mgranger@laika.com>
parents: 2
diff changeset
   711
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   712
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   713
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   714
	#########
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   715
	protected
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   716
	#########
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   717
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   718
	### Just return the contents of the provided +file+, rooted
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   719
	### in the list directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   720
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   721
	def read( file )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   722
		file = self.listdir + file unless file.is_a?( Pathname )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   723
		return file.read.chomp
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   724
	rescue
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   725
		nil
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   726
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   727
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   728
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   729
	### Overwrite +file+ safely, yielding the open filehandle to the
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   730
	### block.  Set the new file to correct ownership and permissions.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   731
	###
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   732
	def write( file, &block )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   733
		file = self.listdir + file unless file.is_a?( Pathname )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   734
		self.with_safety do
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   735
			file.open( 'w' ) do |f|
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   736
				yield( f )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   737
			end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   738
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   739
			stat = self.listdir.stat
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   740
			file.chown( stat.uid, stat.gid )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   741
			file.chmod( 0600 )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   742
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   743
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   744
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   745
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   746
	### Simply create an empty file, safely.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   747
	###
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   748
	def touch( *file )
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   749
		self.with_safety do
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   750
			Array( file ).flatten.each do |f|
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   751
				f = self.listdir + f unless f.is_a?( Pathname )
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   752
				f.open( 'w' ) {}
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   753
			end
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   754
		end
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   755
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   756
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   757
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   758
	### Delete +file+ safely.
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   759
	###
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   760
	def unlink( *file )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   761
		self.with_safety do
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   762
			Array( file ).flatten.each do |f|
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   763
				f = self.listdir + f unless f.is_a?( Pathname )
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   764
				next unless f.exist?
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   765
				f.unlink
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
   766
			end
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   767
		end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   768
	end
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   769
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   770
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   771
	### Return a Pathname to a subscription directory.
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
	def subscription_dir( section=nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   774
		if section
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   775
			unless SUBSCRIPTION_DIRS.include?( section )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   776
				raise "Invalid subscription dir: %s, must be one of: %s" % [
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   777
					section,
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   778
					SUBSCRIPTION_DIRS.join( ', ' )
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   779
				]
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   780
			end
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   781
			return self.listdir + section + 'subscribers'
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   782
		else
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   783
			return self.listdir + 'subscribers'
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   784
		end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   785
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   786
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   787
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   788
	### Read the hashed subscriber email addresses from the specified
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 13
diff changeset
   789
	### +directory+ and return them in an Array.
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   790
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   791
	def read_subscriber_dir( section=nil )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   792
		directory = self.subscription_dir( section )
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   793
		rval = []
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   794
		Pathname.glob( directory + '*' ) do |hashfile|
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   795
			rval.push( hashfile.read.scan(/T([^\0]+)\0/) )
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   796
		end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   797
13
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   798
		return rval.flatten.sort
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   799
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   800
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   801
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   802
	### Return a Pathname object for the list owner's home directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   803
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   804
	def homedir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   805
		user = Etc.getpwuid( self.listdir.stat.uid )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   806
		return Pathname( user.dir )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   807
	end
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   808
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   809
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   810
	### Safely make modifications to a file within a list directory.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   811
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   812
	### 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
   813
	### atomic -- if an incoming message hits when a sticky
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   814
	### is set, it is deferred to the Qmail queue.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   815
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   816
	###   - Set sticky bit on the list directory owner's homedir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   817
	###   - Make changes with the block
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   818
	###   - Unset sticky (just back to what it was previously)
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   819
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   820
	### All writes should be wrapped in this method.
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   821
	###
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   822
	def with_safety( &block )
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   823
		home = self.homedir
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   824
		mode = home.stat.mode
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   825
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   826
		home.chmod( mode | 01000 ) # enable sticky
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   827
		yield
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   828
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   829
	ensure
a03c08c289e9 Multiple changes.
Mahlon E. Smith <mahlon@martini.nu>
parents: 12
diff changeset
   830
		home.chmod( mode )
2
7b5a0131d5cd Added more list-config accessors
Michael Granger <mgranger@laika.com>
parents: 1
diff changeset
   831
	end
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
   832
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   833
end # class Ezmlm::List
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 5
diff changeset
   834