]> nos-oignons.net Git - gestion-adh.git/blob - lib/nos_oignons/mailman.rb
Enable Member#filename_for_id to work with strings
[gestion-adh.git] / lib / nos_oignons / mailman.rb
1 #-*- coding: utf-8 -*-
2
3 require 'shellwords'
4
5 module NosOignons
6   module Mailman
7     class << self
8       def list_members(list)
9         `sudo -u list list_members #{Shellwords.escape(list)}`.strip.split
10       end
11
12       def add_member(list, email)
13         add_members(list, [email])
14       end
15
16       def add_members(list, emails)
17         IO.popen(['sudo', '-u', 'list', 'add_members', '-r', '-', list], 'w') do |io|
18           emails.each do |email|
19             io.puts email
20           end
21         end
22       end
23
24       def remove_member(list, email)
25         remove_members(list, [email])
26       end
27
28       def remove_members(list, emails)
29         IO.popen(['sudo', '-u', 'list', 'remove_members', '-f', '-', list], 'w') do |io|
30           emails.each do |email|
31             io.puts email
32           end
33         end
34       end
35     end
36   end
37 end