-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
policy.js
43 lines (38 loc) · 1.06 KB
/
policy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-FileCopyrightText: 2023 the cable-client authors
//
// SPDX-License-Identifier: AGPL-3.0-or-later
class ReplicationPolicy {
constructor() {
this.limit = 0 /* # of posts */
this.windowSize = 0 /* ms */
}
}
class JoinedPolicy extends ReplicationPolicy {
constructor(opts) {
super()
if (!opts) { opts = {} }
this.limit = opts.limit || 0 /* # of posts */ // no limit
this.windowSize = opts.windowSize || 2 * 10 * 7 * 24 * 60 * 60 * 1000 /* 2 * 10 weeks in ms */
}
}
class UnjoinedPolicy extends ReplicationPolicy {
constructor(opts) {
super()
if (!opts) { opts = {} }
this.limit = opts.limit || 1000 /* # of posts */
this.windowSize = opts.windowSize || 2 * 10 * 7 * 24 * 60 * 60 * 1000 /* 2 * 10 weeks in ms */
}
}
class DroppedPolicy extends ReplicationPolicy {
constructor(opts) {
super()
if (!opts) { opts = {} }
this.limit = opts.limit || 0 /* # of posts */
this.windowSize = opts.windowSize || 0 /* 0 weeks in ms */
}
}
module.exports = {
JoinedPolicy,
UnjoinedPolicy,
DroppedPolicy
}