mirror of
https://github.com/jech/galene.git
synced 2024-11-25 18:15:57 +01:00
Implement "expires" and "not-before" for groups.
This commit is contained in:
parent
4fe31b4863
commit
de0c42faaf
3 changed files with 24 additions and 0 deletions
2
README
2
README
|
@ -157,6 +157,8 @@ nobody will be able to join the group. The following fields are allowed:
|
||||||
a time;
|
a time;
|
||||||
- `max-history-age`: the time, in seconds, during which chat history is
|
- `max-history-age`: the time, in seconds, during which chat history is
|
||||||
kept (default 14400, i.e. 4 hours);
|
kept (default 14400, i.e. 4 hours);
|
||||||
|
- `not-before` and `expires`: the times (in ISO 8601 or RFC 3339 format)
|
||||||
|
between which joining the group is allowed;
|
||||||
- `allow-recording`: if true, then recording is allowed in this group;
|
- `allow-recording`: if true, then recording is allowed in this group;
|
||||||
- `unrestricted-tokens`: if true, then ordinary users (without the "op"
|
- `unrestricted-tokens`: if true, then ordinary users (without the "op"
|
||||||
privilege) are allowed to create tokens;
|
privilege) are allowed to create tokens;
|
||||||
|
|
|
@ -46,6 +46,12 @@ type Description struct {
|
||||||
// The time for which history entries are kept.
|
// The time for which history entries are kept.
|
||||||
MaxHistoryAge int `json:"max-history-age,omitempty"`
|
MaxHistoryAge int `json:"max-history-age,omitempty"`
|
||||||
|
|
||||||
|
// Time after which joining is no longer allowed
|
||||||
|
Expires *time.Time `json:"expires"`
|
||||||
|
|
||||||
|
// Time before which joining is not allowed
|
||||||
|
NotBefore *time.Time `json:"not-before,omitempty"`
|
||||||
|
|
||||||
// Whether users are allowed to log in with an empty username.
|
// Whether users are allowed to log in with an empty username.
|
||||||
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
||||||
|
|
||||||
|
|
|
@ -607,6 +607,22 @@ func AddClient(group string, c Client, creds ClientCredentials) (*Group, error)
|
||||||
}
|
}
|
||||||
return nil, UserError(m)
|
return nil, UserError(m)
|
||||||
}
|
}
|
||||||
|
if g.description.NotBefore != nil ||
|
||||||
|
g.description.Expires != nil {
|
||||||
|
now := time.Now()
|
||||||
|
if g.description.NotBefore != nil &&
|
||||||
|
g.description.NotBefore.After(now) {
|
||||||
|
return nil, UserError(
|
||||||
|
"this group is not open yet",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if g.description.Expires != nil &&
|
||||||
|
g.description.Expires.Before(now) {
|
||||||
|
return nil, UserError(
|
||||||
|
"this group is closed",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
if g.description.Autokick {
|
if g.description.Autokick {
|
||||||
ops := false
|
ops := false
|
||||||
for _, c := range clients {
|
for _, c := range clients {
|
||||||
|
|
Loading…
Reference in a new issue