sugoi-mail 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/CHANGELOG +38 -0
  2. data/app/apis/mailservice_api.rb +6 -0
  3. data/app/controllers/account_controller.rb +40 -45
  4. data/app/controllers/{root_admin_controller.rb → admin_controller.rb} +1 -2
  5. data/app/controllers/application.rb +9 -9
  6. data/app/controllers/mailinglist_class_controller.rb +63 -0
  7. data/app/controllers/mailinglist_controller.rb +22 -45
  8. data/app/controllers/mailservice_controller.rb +7 -0
  9. data/app/models/mailinglist_class.rb +40 -0
  10. data/app/models/message.rb +8 -7
  11. data/app/views/account/welcome.rhtml +2 -2
  12. data/app/views/{root_admin → admin}/_form.rhtml +3 -3
  13. data/app/views/{root_admin → admin}/add_address.rhtml +0 -0
  14. data/app/views/{root_admin → admin}/add_mailinglist.rhtml +0 -0
  15. data/app/views/{root_admin → admin}/admin_user_list.rhtml +0 -0
  16. data/app/views/{root_admin → admin}/admin_user_new.rhtml +0 -0
  17. data/app/views/{root_admin → admin}/change_user_password.rhtml +0 -0
  18. data/app/views/{root_admin → admin}/edit_address.rhtml +0 -0
  19. data/app/views/{root_admin → admin}/edit_mailinglist.rhtml +0 -0
  20. data/app/views/{root_admin → admin}/edit_user_list.rhtml +0 -0
  21. data/app/views/{root_admin → admin}/list_addresses.rhtml +0 -0
  22. data/app/views/{root_admin → admin}/list_mailinglists.rhtml +0 -0
  23. data/app/views/{root_admin → admin}/list_users.rhtml +3 -3
  24. data/app/views/{root_admin → admin}/remove_address.rhtml +0 -0
  25. data/app/views/{root_admin → admin}/remove_mailinglist.rhtml +0 -0
  26. data/app/views/{root_admin → admin}/remove_user.rhtml +0 -0
  27. data/app/views/{root_admin → admin}/show_user.rhtml +0 -0
  28. data/app/views/layouts/application.rhtml +1 -1
  29. data/app/views/mailinglist/edit.rhtml +1 -1
  30. data/app/views/mailinglist_class/_form.rhtml +31 -0
  31. data/app/views/mailinglist_class/_form_option.rhtml +14 -0
  32. data/app/views/mailinglist_class/_new_form.rhtml +16 -0
  33. data/app/views/mailinglist_class/edit.rhtml +15 -0
  34. data/app/views/{mailinglist/list_mailinglist_classes.rhtml → mailinglist_class/list.rhtml} +5 -4
  35. data/app/views/mailinglist_class/new.rhtml +10 -0
  36. data/app/views/mailinglist_class/show.rhtml +9 -0
  37. data/app/views/navigation/_nav_module.rhtml +13 -13
  38. data/app/views/navigation/_root_add_address_module.rhtml +1 -1
  39. data/app/views/navigation/_root_add_mailinglist_module.rhtml +1 -1
  40. data/app/views/navigation/_root_add_user_module.rhtml +1 -1
  41. data/app/views/navigation/_root_change_user_password_module.rhtml +1 -1
  42. data/app/views/navigation/_root_edit_address_module.rhtml +5 -5
  43. data/app/views/navigation/_root_edit_mailinglist_module.rhtml +5 -5
  44. data/app/views/navigation/_root_edit_user_list_module.rhtml +1 -1
  45. data/app/views/navigation/_root_edit_user_module.rhtml +4 -4
  46. data/app/views/navigation/_root_index_module.rhtml +2 -2
  47. data/app/views/navigation/_root_list_addresses_module.rhtml +4 -4
  48. data/app/views/navigation/_root_list_mailinglists_module.rhtml +3 -3
  49. data/app/views/navigation/_root_list_users_module.rhtml +4 -4
  50. data/app/views/navigation/_root_remove_address_module.rhtml +4 -4
  51. data/app/views/navigation/_root_remove_mailinglist_module.rhtml +4 -4
  52. data/app/views/navigation/_root_remove_user_module.rhtml +4 -4
  53. data/app/views/navigation/_root_show_user_module.rhtml +4 -4
  54. data/app/views/navigation/_root_welcome_module.rhtml +2 -2
  55. data/db/schema.rb +108 -0
  56. data/lib/gurgitate-rules.rb +3 -8
  57. data/lib/tasks/release.rake +1 -1
  58. data/public/stylesheets/global.css +58 -2
  59. data/test/functional/{root_admin_controller_test.rb → admin_controller_test.rb} +4 -4
  60. data/test/unit/mailinglist_class_test.rb +11 -0
  61. metadata +32 -24
  62. data/app/views/mailinglist/_new_class_form.rhtml +0 -16
  63. data/app/views/mailinglist/new_mailinglist_class.rhtml +0 -8
@@ -0,0 +1,38 @@
1
+ New features for version 0.3.x
2
+
3
+ - MailinglistClass has recieved many changes
4
+ - duplicate mailinglist_class names are dissallowed (throws error)
5
+ - deleting a mailinglist_class that still has mailing lists assigned to it is dissallowed (throws error)
6
+ - blank mailinglist class name is dissalowed (what a shame..)
7
+ - help/gui functions added:
8
+ MailinglistClass.get_param_names:
9
+ prints string-array of all param/setting names
10
+ MailinglistClass.get_param_description(param_name, html=false):
11
+ prints description of the parameter (for gui/helpfile use). if html is true, all newlines are replaced with line-breaks <br/>
12
+ - a mailinglist class controller & views have been created
13
+ reuses the same form for Show, Edit, and New, with detailed info
14
+
15
+ New features for version 0.3.0
16
+
17
+ - improved maild daemon:
18
+ - implemented cleanup features (removes socketfile & pidfile on kill)
19
+ - uses a non-blocking socket
20
+ - catches kill -2 (SIGINT) and kill -15 (SIGTERM) and cleans up
21
+ - added a bash bootscript:
22
+ - located in script/boot/
23
+ - allows start, stop, cleanup, status, and help
24
+ - cleanup restores any error state to a stopped state
25
+ - message.rb's deliver method rewritten:
26
+ - uses only envelope_to, and envelope_from data
27
+ - envelope data is generated in a separate method (generate_envelope_data)
28
+ - envelope_to is now a serialized array in the DB (why wasn't it before?)
29
+ - Mailinglist.subscribe now accepts address objects and strings
30
+
31
+ - fixed sugoi_admin's create_user function. Now the default mailinglist has the user's address subscribed, so a confirmation code is created and an email is sent to the user
32
+
33
+ - mailinglist.rb disallows subscribing a private address to more than one forwarding address (so Address.proxy_address doesn't get confused)
34
+
35
+ - updated everything to rails 2.0 syntax (no more depreciation warnings)
36
+ - the 'dumptofile' debug script has been added to script (for mailjail setup)
37
+ - gurgitate rules updated to new changes
38
+ - a significant amount of test fixtures & unit-tests updates
@@ -165,6 +165,12 @@ class MailserviceApi < ActionWebService::API::Base
165
165
  { :address => :string }
166
166
  ]
167
167
 
168
+ api_method :mailinglist_unsubscribe_quiet, :returns => [ :bool ],
169
+ :expects => [
170
+ { :mailinglist_id => :integer },
171
+ { :address => :string }
172
+ ]
173
+
168
174
  ## TODO: Implement message handling functionality
169
175
  ## api_method :mailinglist_messages, :returns => [ [ :integer ] ],
170
176
  ## :expects => [
@@ -1,55 +1,50 @@
1
1
  class AccountController < ApplicationController
2
- include LoginSystem
2
+ include LoginSystem
3
3
 
4
- def signup
5
- if request.post?
6
- @user = User.new(params[:user])
7
- if @user.save
8
- session[:user] = User.authenticate(@user.login, params[:user][:password])
9
- flash['notice'] = "Signup successful"
10
- redirect_back_or_default :action => "welcome"
11
- end
4
+ def index
5
+ redirect_to :action => "welcome"
12
6
  end
13
- end
7
+
8
+ def signup
9
+ if request.post?
10
+ @user = User.new(params[:user])
11
+ if @user.save
12
+ session[:user_id] = User.authenticate(@user.login, params[:user][:password]).id
13
+ flash['notice'] = "Signup successful"
14
+ redirect_back_or_default :action => "welcome"
15
+ end
16
+ end
17
+ end
14
18
 
15
- def logout
16
- session[:navList] = :logout
17
- session[:user] = nil
18
- redirect_back_or_default :action => "login"
19
- end
19
+ def logout
20
+ session[:navList] = :logout
21
+ session[:user_id] = nil
22
+ redirect_back_or_default :action => "login"
23
+ flash.now['notice'] = "Logout successfully"
24
+ end
20
25
 
21
- def login
22
- case request.method
23
- when :post
24
- if session[:user] = User.authenticate(params[:user_login], params[:user_password])
25
- session[:user_id] = :id # THIS MIGHT BE WRONG, SUPPOSED TO BE ABLE TO ACCESS USER'S BY ID STORED IN SESSION
26
- flash['notice'] = "Login successful"
27
- redirect_back_or_default :action => "welcome"
28
- else
29
- flash.now['notice'] = "Login unsuccessful"
26
+ def login
27
+ case request.method
28
+ when :post
29
+ if usr=User.authenticate(params[:user_login], params[:user_password])
30
+ session[:user_id] = usr.id
31
+ flash['notice'] = usr.login "'s login successful"
32
+ redirect_back_or_default :action => "welcome"
33
+ else
34
+ flash.now['notice'] = "Login unsuccessful"
30
35
 
31
- @login = params[:user_login]
32
- end
36
+ end
37
+ end
33
38
  end
34
- end
35
39
 
36
- def welcome
37
- @controller_name = controller_name
38
- @action_name = action_name
39
- session[:user] = User.find session[:user].id
40
-
41
- @mailinglists = session[:user].mailinglists
42
-
43
- @mailinglist_classes = MailinglistClass.find(:all)
44
-
45
- domain_name = session[:domain]
46
- domain = Domain.find_by_name domain_name
47
- if domain then
48
- @users = User.find_all_by_domain_id domain.id
49
- else
50
- # error "Domain \"#{domain_name}\" does not exist."
51
- end
52
- #session[:navList] = :welcome //not needed??
53
- end
40
+ def welcome
41
+ if session[:user_id] then
42
+ @user = User.find(session[:user_id])
43
+ @mailinglists = @user.mailinglists
44
+ @users = User.find_all_by_domain_id @user.domain.id
45
+ else
46
+ redirect_back_or_default :action => "login"
47
+ end
48
+ end
54
49
 
55
50
  end
@@ -1,7 +1,6 @@
1
- class RootAdminController < MailserviceController
1
+ class AdminController < ApplicationController
2
2
 
3
3
  def admin_user_new
4
-
5
4
  end
6
5
 
7
6
  # Returns true if the user is an administrator and false otherwise
@@ -1,15 +1,15 @@
1
1
  # Filters added to this controller will be run for all controllers in the application.
2
2
  # Likewise, all the methods added will be available for all controllers.
3
3
  class ApplicationController < ActionController::Base
4
- before_filter :initialize_variables
5
-
6
- protected
4
+ before_filter :initialize_variables
7
5
 
8
- def initialize_variables
9
- @controller_name = controller_name
10
- @action_name = action_name
11
- @users = User.find(:all)
12
- @mailinglist_classes = MailinglistClass.find(:all)
13
- end
6
+ protected
7
+
8
+ def initialize_variables
9
+ @controller_name = controller_name
10
+ @action_name = action_name
11
+ @users = User.find(:all)
12
+ @mailinglist_classes = MailinglistClass.find(:all)
13
+ end
14
14
 
15
15
  end
@@ -0,0 +1,63 @@
1
+ class MailinglistClassController < ApplicationController
2
+ verify :session => :user_id,
3
+ :add_flash => { :notice => 'You are not logged in!'},
4
+ :redirect_to => { :controller => 'account', :action => 'welcome' }
5
+ verify :only => [ 'show', 'edit', 'remove' ],
6
+ :params => :id,
7
+ :add_flash => { :notice => 'Missing mailinglist class ID.' },
8
+ :redirect_to => { :action => 'list' }
9
+
10
+
11
+ def new
12
+ @domain = User.find(session[:user_id]).domain
13
+
14
+ if request.post?
15
+ @mailinglist_class = MailinglistClass.new(params[:mailinglist_class])
16
+ if @mailinglist_class.save
17
+ flash[:notice] = 'The mailinglist class was successfully added.'
18
+ redirect_to :controller => "account", :action => "welcome"
19
+ else
20
+ flash[:notice] = 'ERR: the class could not be created'
21
+ end
22
+ end
23
+ end
24
+
25
+ def remove
26
+ if request.post?
27
+ begin
28
+ MailinglistClass.find(params[:id]).destroy
29
+ rescue MlClassInUseException
30
+ flash[:notice] = 'Cannot remove a mailinglist class that is currently in use.'
31
+ redirect_to :controller => 'account', :action => 'welcome'
32
+ return
33
+ end
34
+
35
+ flash[:notice] = 'The mailinglist class was successfully removed.'
36
+ redirect_to :controller => 'account', :action => 'welcome'
37
+
38
+ else
39
+ flash[:notice] = 'Click Delete to remove the mailinglist class.'
40
+ redirect_to :action => 'edit', :id => params[:id]
41
+ end
42
+ end
43
+
44
+ def edit
45
+ @user = User.find(session[:user_id])
46
+ @mailinglist_class = MailinglistClass.find(params[:id])
47
+
48
+
49
+ if request.post?
50
+ if @mailinglist_class.update_attributes(params[:mailinglist_class])
51
+ if @mailinglist_class.save
52
+ flash[:notice] = 'The mailinglist class was successfully edited.'
53
+ redirect_to :controller => 'account', :action => 'welcome'
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ def show
60
+ @mailinglist_class = MailinglistClass.find(params[:id])
61
+ end
62
+
63
+ end
@@ -1,15 +1,17 @@
1
1
  class MailinglistController < ApplicationController
2
+ verify :session => :user_id,
3
+ :add_flash => { :notice => 'You are not logged in!'},
4
+ :redirect_to => { :controller => 'account', :action => 'welcome' }
2
5
  verify :only => [ 'show', 'edit', 'remove' ],
3
6
  :params => :id,
4
7
  :add_flash => { :notice => 'Missing mailinglist ID.' },
5
8
  :redirect_to => { :action => 'list' }
6
9
 
7
10
  def remove
8
- flash[:notice] = 'The mailing list was successfully destroyed.'
9
11
  if request.post?
10
12
  Mailinglist.find(params[:id]).destroy
11
13
  flash[:notice] = 'The mailinglist was successfully destroyed.'
12
- redirect_to :controller => "account", :action => 'welcome'
14
+ redirect_to :controller => 'account', :action => 'welcome'
13
15
  else
14
16
  flash[:notice] = 'Click Destroy to destroy the mailinglist.'
15
17
  redirect_to :action => 'edit', :id => params[:id]
@@ -17,51 +19,44 @@ class MailinglistController < ApplicationController
17
19
  end
18
20
 
19
21
  def edit
20
- #session[:mailinglist_id] = params[:id]
22
+ @mailinglist = Mailinglist.find(params[:id])
21
23
  if request.post?
22
- @mailinglist = Mailinglist.find(params[:id])
23
24
  if @mailinglist.update_attributes(params[:mailinglist])
24
25
  @mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
25
- if @mailinglist.save
26
- flash[:notice] = 'The mailinglist was successfully edited.'
27
- session[:user] = User.find session[:user].id
28
- redirect_to :action => 'show', :id => @mailinglist
29
- end
26
+ if @mailinglist.save
27
+ flash[:notice] = 'The mailinglist was successfully edited.'
28
+ redirect_to :action => 'show', :id => @mailinglist
29
+ end
30
30
  end
31
- else
32
- @mailinglist = Mailinglist.find(params[:id])
33
31
  end
34
32
  end
35
33
 
36
34
  def list
37
- session[:user] = User.find session[:user].id
38
- @mailinglists = session[:user].mailinglists
35
+ @user = User.find session[:user_id]
36
+ @mailinglists = @user.mailinglists
39
37
  # @mailinglist_pages, @mailinglists = paginate(:mailinglists)
40
38
  end
41
39
 
42
40
  def new
43
- session[:domain] = Domain.find(session[:domain_id])
41
+ @user = User.find(session[:user_id])
42
+ @domain = @user.domain
43
+
44
44
  if request.post?
45
45
  @mailinglist = Mailinglist.new(params[:mailinglist])
46
- domain = session[:domain]
47
- if domain then
48
- @mailinglist.user = User.find_by_login_and_domain_id params[:user], domain.id
49
- @mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
50
- if @mailinglist.save
51
- flash[:notice] = 'A new mailinglist was successfully added.'
52
- session[:user] = User.find session[:user].id
53
- redirect_to :action => 'list'
54
- end
55
- else
56
- flash[:notice] = 'Mailinglist could not be added - domain is nil'
57
- end
46
+ @mailinglist.user = @user
47
+ @mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
48
+ if @mailinglist.save
49
+ flash[:notice] = @mailinglist.name + ' was successfully added.'
50
+ redirect_to :action => 'list'
51
+ else
52
+ flash[:error] = 'ERR: The mailing list could not be added'
53
+ end
58
54
  else
59
55
  #@mailinglist = Mailinglist.new
60
56
  end
61
57
  end
62
58
 
63
59
  def show
64
- session[:user] = User.find session[:user].id
65
60
  @mailinglist = Mailinglist.find(params[:id])
66
61
  end
67
62
 
@@ -84,22 +79,4 @@ class MailinglistController < ApplicationController
84
79
  end
85
80
  end
86
81
 
87
- def new_mailinglist_class
88
- session[:domain] = Domain.find(session[:domain_id])
89
- if request.post?
90
- @mailinglist_class = MailinglistClass.new(params[:mailinglist_class])
91
- domain = session[:domain]
92
- if domain then
93
- #@mailinglist.user = User.find_by_login_and_domain_id params[:user], domain.id
94
- #@mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
95
- if @mailinglist_class.save
96
- flash[:notice] = 'A new mailinglist class was successfully added.'
97
- session[:user] = User.find session[:user].id
98
- redirect_to :controller => "account", :action => "welcome"
99
- end
100
- else
101
- flash[:notice] = 'Mailinglist class could not be added - domain is nil'
102
- end
103
- end
104
- end
105
82
  end
@@ -487,6 +487,13 @@ class MailserviceController < ApplicationController
487
487
  end
488
488
  end
489
489
 
490
+ # Removes an address from a mailing list without sending the
491
+ # farewell message
492
+ def mailinglist_unsubscribe_quiet mailinglist_id, address
493
+ if my_mailing_list(mailinglist_id).unsubscribe(address, false)
494
+ true
495
+ end
496
+ end
490
497
  end
491
498
 
492
499
  ## TODO: implement message-handling functionality properly
@@ -34,7 +34,47 @@
34
34
  # mailing list archives online)
35
35
  # false: Messages will be discarded after delivery (probably what
36
36
  # people who want to use sugoi-mail for forwarding want)
37
+ class MlClassInUseException < Exception; end
38
+
37
39
  class MailinglistClass < ActiveRecord::Base
38
40
  has_many :mailinglists
41
+ validates_presence_of :name
42
+ validates_uniqueness_of :name
43
+
44
+ def before_destroy
45
+ if ml = Mailinglist.find_by_mailinglist_class_id(self.id)
46
+ raise MlClassInUseException
47
+ end
48
+ end
49
+
50
+ public
51
+
52
+ def self.get_param_names
53
+ return %w{public closed moderated confirmation joinable archived}
54
+ end
39
55
 
56
+ def self.get_param_description(param, html = false)
57
+ case param
58
+ when 'public'
59
+ param_desc = "Whether the list is open to the public or not.\nIf checked, anyone can post to the list.\nIf unchecked, only members of the mailing list can post to it."
60
+ when 'closed'
61
+ param_desc = "Determines who can send mail to the mailing list.\nIf checked, only the owner can send mail.\nIf unchecked, other people can post to it as determined by the \"Public\" parameter."
62
+ when 'moderated'
63
+ param_desc = "Determines if the owner has to approve every message posted to the mailing list.\nIf checked, all posted messages go to owner first.\nIf unchecked, all posted messages are sent to the list immediately."
64
+ when 'confirmation'
65
+ param_desc = "Determines whether a newly subscribed address requires subscription-confirmation from the user (via e-mail).\nIf checked, subscriptions have to be confirmed by the subscriber.\nIf unchecked, subscriptions will happen automatically."
66
+ when 'joinable'
67
+ param_desc = "Determines whether the general public can join this mailinglist.\nIf checked, anyone can subscribe to the list at will by sending email to _listname_-request@_domain_.\nIf unchecked, then only the owner can subscribe/unsubscribe people."
68
+ when 'archived'
69
+ param_desc = "Determines whether the messages are retained after delivery.\nIf checked, then messages are archived (useful for viewing online archives).\nIf unchecked, then messages are discarded after delivery (recommended for the mail-forwarding feature, for privacy concerns)."
70
+ else
71
+ param_desc = "'" + param.to_s + "' is not a valid mailing class parameter"
72
+ end
73
+
74
+ if html then
75
+ param_desc.gsub!(/\n/, '<br/>')
76
+ end
77
+
78
+ return param_desc
79
+ end
40
80
  end
@@ -240,7 +240,9 @@ class Message < ActiveRecord::Base
240
240
  else
241
241
  self.envelope_to = mailinglist.expand_addresses.map { |a| a.address }
242
242
  end
243
- self.envelope_from = mailinglist.name + SysConfig.address_separator + SysConfig.bounce_suffix + "@" + mailinglist.user.domain.name
243
+ self.envelope_from = mailinglist.name +
244
+ SysConfig.address_separator +
245
+ SysConfig.bounce_suffix + "@" + mailinglist.user.domain.name
244
246
 
245
247
  end
246
248
 
@@ -257,7 +259,7 @@ class Message < ActiveRecord::Base
257
259
  if mailinglist.canonical_address? or mailinglist.closed? then
258
260
  proxify_addresses
259
261
  else
260
- @mess.to_s
262
+ to_s
261
263
  end
262
264
  end
263
265
 
@@ -272,7 +274,7 @@ class Message < ActiveRecord::Base
272
274
  smtpdetails = {}
273
275
  end
274
276
 
275
- # Hm, not sure why this is *here* instead of somewhere
277
+ # Hm, not sure why this is *here* instead of somewhere
276
278
  # else. Fix later.
277
279
  #
278
280
  # (This should actually be in the database somewhere, I'm thinking.)
@@ -288,7 +290,9 @@ class Message < ActiveRecord::Base
288
290
  end
289
291
 
290
292
  if mailinglist.closed?
291
- unless mailinglist.user.mailinglist.has_address? self.envelope_from or mailinglist.user.address == self.envelope_from then
293
+ unless mailinglist.user.mailinglist.has_address? \
294
+ self.envelope_from or \
295
+ mailinglist.user.address == self.envelope_from then
292
296
  return bounce
293
297
  end
294
298
  end
@@ -299,9 +303,6 @@ class Message < ActiveRecord::Base
299
303
  return bounce
300
304
  end
301
305
 
302
- #Good debugging thingy:
303
- #pp self
304
-
305
306
  Net::SMTP.start(smtpserver, smtpport, mysmtpname) do |smtp|
306
307
  smtp.send_message messagetext(smtpdetails), self.envelope_from, self.envelope_to
307
308
  end