simple_mailing_list 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.md +7 -6
- data/lib/simple_mailing_list/delete_old.rb +10 -6
- data/lib/simple_mailing_list/main.rb +1 -1
- data/lib/simple_mailing_list/setup.rb +1 -0
- data/lib/simple_mailing_list/version.rb +1 -1
- data/lib/simple_mailing_list.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17c2c77915c5e0a76917d09694ae169b748a8452
|
4
|
+
data.tar.gz: 23f0b3d46cf1177824ba537adfab98d0b5adac95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c5662a1f771e384b6aafa869866c8b87b31c0ec08a5eabc7ec17bd72c5eabd1b3588a14f9823b6df1d5575693d6513ea1ed43b2929507a51ee8588c4227e68d
|
7
|
+
data.tar.gz: 68f7d6c4dfd8e750f1d68224a30821ad40060ef118c8339c7fe7fc55b67b1a916deb9b778f35b95f25301e8e95eba3ba414ded584f84fd4a492ccf95203c1593
|
data/README.ja.md
CHANGED
@@ -28,17 +28,18 @@
|
|
28
28
|
|
29
29
|
- 送信可能なメールアドレス1つ
|
30
30
|
- 受信可能なメールアドレス3つ以上
|
31
|
-
- Linux など、プロセスを Daemon
|
31
|
+
- Linux など、プロセスを Daemon 化可能な Ruby 環境のコンピュータ1台
|
32
32
|
|
33
33
|
## インストール
|
34
34
|
|
35
|
-
Gemfile
|
35
|
+
以下のような Gemfile を作成し、```$ bundle install```
|
36
36
|
|
37
37
|
```ruby
|
38
38
|
gem 'simple_mailing_list'
|
39
39
|
gem 'sqlite3'
|
40
40
|
# gem 'mysql2'
|
41
41
|
# gem 'pg'
|
42
|
+
# ↑ 使用したい DB に応じて変更。
|
42
43
|
```
|
43
44
|
|
44
45
|
または、以下のようにしてインストール:
|
@@ -49,11 +50,11 @@ gem 'sqlite3'
|
|
49
50
|
|
50
51
|
YAML 形式のコンフィグファイルを用意し、
|
51
52
|
|
52
|
-
$ simple_mailing_list setup -c <config.yaml>
|
53
|
+
$ bundle exec simple_mailing_list setup -c <config.yaml>
|
53
54
|
|
54
|
-
|
55
|
+
でデータベースやディレクトリを作成する。(※ bundler 不使用の場合は ```bundle exec``` 不要。)
|
55
56
|
|
56
|
-
$ simple_mailing_list <mode> -c <config.yaml>
|
57
|
+
$ bundle exec simple_mailing_list <mode> -c <config.yaml>
|
57
58
|
|
58
59
|
で実行。
|
59
60
|
|
@@ -65,7 +66,7 @@ YAML 形式のコンフィグファイルを用意し、
|
|
65
66
|
|
66
67
|
### Daemon 化
|
67
68
|
|
68
|
-
$ daemons_simple_mailing_list start -- loop_main_jobs -c <config.yaml>
|
69
|
+
$ bundle exec daemons_simple_mailing_list start -- loop_main_jobs -c <config.yaml>
|
69
70
|
|
70
71
|
で、「メールの受信・処理」「古いデータの削除」といった一連の処理をずっと繰り返します。
|
71
72
|
|
@@ -5,18 +5,22 @@ module SimpleMailingList
|
|
5
5
|
module System
|
6
6
|
private
|
7
7
|
|
8
|
-
def
|
8
|
+
def _disable_failed_users(failed_count = 10, time = 5 * 24 * 60 * 60, reset = true)
|
9
9
|
@log.debug "Delete failed users."
|
10
10
|
last_failed_at = Time.now - time
|
11
11
|
users = User.where("last_failed_at > ? AND failed_count > ?", last_failed_at, failed_count)
|
12
12
|
users.each do |user|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
User.find_each do |user|
|
17
|
-
user.failed_count = 0
|
13
|
+
next if user.enabled == 0
|
14
|
+
@log.info "disable user[#{user.mail_address}]"
|
15
|
+
user.enabled = 0
|
18
16
|
user.save
|
19
17
|
end
|
18
|
+
if reset
|
19
|
+
User.where(enabled: 1).each do |user|
|
20
|
+
user.failed_count = 0
|
21
|
+
user.save
|
22
|
+
end
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
def _delete_old_confirmations()
|
@@ -198,7 +198,7 @@ module SimpleMailingList
|
|
198
198
|
|
199
199
|
sendmail = create_forward_mail(mail, subject)
|
200
200
|
|
201
|
-
users = User.
|
201
|
+
users = User.where(enabled: 1).to_a.select do |user|
|
202
202
|
user_options = JSON.parse(user.options)
|
203
203
|
!forward_options.keys.any?{ |key| forward_options[key] != user_options[key] }
|
204
204
|
end
|
@@ -10,6 +10,7 @@ module SimpleMailingList
|
|
10
10
|
ActiveRecord::Base.transaction do |a|
|
11
11
|
ActiveRecord::Migration.create_table :users do |t|
|
12
12
|
t.text :mail_address , null: false
|
13
|
+
t.integer :enabled , null: false, default: 1
|
13
14
|
t.integer :failed_count , null: false, default: 0
|
14
15
|
t.timestamp :last_failed_at , null: false, default: Time.at(0)
|
15
16
|
t.text :options , null: false, default: "{}"
|
data/lib/simple_mailing_list.rb
CHANGED
@@ -55,7 +55,7 @@ module SimpleMailingList
|
|
55
55
|
_delete_user(address)
|
56
56
|
end
|
57
57
|
|
58
|
-
desc "
|
58
|
+
desc "disable_failed_users", "disable users who do not receive mails."
|
59
59
|
option :failed_count,
|
60
60
|
aliases: "-f",
|
61
61
|
default: 10,
|
@@ -64,10 +64,13 @@ module SimpleMailingList
|
|
64
64
|
aliases: "-t",
|
65
65
|
default: 5 * 24 * 60 * 60,
|
66
66
|
type: :numeric
|
67
|
-
|
67
|
+
option :reset,
|
68
|
+
default: false,
|
69
|
+
type: :boolean
|
70
|
+
def disable_failed_users()
|
68
71
|
require "simple_mailing_list/delete_old"
|
69
72
|
load_configfile(options[:configfile])
|
70
|
-
|
73
|
+
_disable_failed_users(options[:failed_count], options[:failed_time], options[:reset])
|
71
74
|
end
|
72
75
|
|
73
76
|
desc "delete_old_confirmations", "delete old confirmations."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_mailing_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|