Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
c769a4aa
Commit
c769a4aa
authored
Jan 17, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add autokick option.
parent
7d216f65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
16 deletions
+45
-16
README
README
+2
-0
group/group.go
group/group.go
+43
-16
No files found.
README
View file @
c769a4aa
...
...
@@ -242,6 +242,8 @@ the group.
are automatically created when first accessed;
- `autolock`: if true, the group will start locked and become locked
whenever there are no clients with operator privileges;
- `autokick`: if true, all clients will be kicked out whenever there are
no clients with operator privileges.
- `redirect`: if set, then attempts to join the group will be redirected
to the given URL; most other fields are ignored in this case;
- `codecs`: this is a list of codecs allowed in this group. The default
...
...
group/group.go
View file @
c769a4aa
...
...
@@ -293,7 +293,7 @@ func Add(name string, desc *description) (*Group, error) {
timestamp
:
time
.
Now
(),
api
:
APIFromNames
(
desc
.
Codecs
),
}
auto
lo
ck
(
g
,
g
.
getClientsUnlocked
(
nil
))
auto
LockKi
ck
(
g
,
g
.
getClientsUnlocked
(
nil
))
groups
.
groups
[
name
]
=
g
return
g
,
nil
}
...
...
@@ -320,7 +320,7 @@ func Add(name string, desc *description) (*Group, error) {
}
g
.
description
=
desc
g
.
api
=
APIFromNames
(
desc
.
Codecs
)
auto
lo
ck
(
g
,
g
.
getClientsUnlocked
(
nil
))
auto
LockKi
ck
(
g
,
g
.
getClientsUnlocked
(
nil
))
return
g
,
nil
}
...
...
@@ -461,10 +461,27 @@ func AddClient(group string, c Client) (*Group, error) {
}
}
clients
:=
g
.
getClientsUnlocked
(
nil
)
if
g
.
clients
[
c
.
Id
()]
!=
nil
{
return
nil
,
ProtocolError
(
"duplicate client id"
)
}
if
!
c
.
Permissions
()
.
Op
&&
g
.
description
.
Autokick
{
ops
:=
false
for
_
,
c
:=
range
clients
{
if
c
.
Permissions
()
.
Op
{
ops
=
true
break
}
}
if
!
ops
{
return
nil
,
UserError
(
"there are no operators in this group"
,
)
}
}
g
.
clients
[
c
.
Id
()]
=
c
g
.
timestamp
=
time
.
Now
()
...
...
@@ -476,25 +493,30 @@ func AddClient(group string, c Client) (*Group, error) {
c
.
PushClient
(
cc
.
Id
(),
uu
,
true
)
cc
.
PushClient
(
c
.
Id
(),
u
,
true
)
}
}(
g
.
getClientsUnlocked
(
c
)
)
}(
clients
)
return
g
,
nil
}
// called locked
func
autolock
(
g
*
Group
,
clients
[]
Client
)
{
if
g
.
locked
==
nil
&&
g
.
description
.
Autolock
{
lock
:=
true
for
_
,
c
:=
range
clients
{
if
c
.
Permissions
()
.
Op
{
lock
=
false
}
}
if
lock
{
m
:=
"this group is locked"
g
.
locked
=
&
m
func
autoLockKick
(
g
*
Group
,
clients
[]
Client
)
{
if
!
(
g
.
description
.
Autolock
&&
g
.
locked
==
nil
)
&&
!
g
.
description
.
Autokick
{
return
}
for
_
,
c
:=
range
clients
{
if
c
.
Permissions
()
.
Op
{
return
}
}
if
g
.
description
.
Autolock
&&
g
.
locked
==
nil
{
m
:=
"this group is locked"
g
.
locked
=
&
m
}
if
g
.
description
.
Autokick
{
go
kickall
(
g
,
"there are no operators in this group"
)
}
}
func
DelClient
(
c
Client
)
{
...
...
@@ -520,7 +542,7 @@ func DelClient(c Client) {
}
}(
clients
)
auto
lo
ck
(
g
,
clients
)
auto
LockKi
ck
(
g
,
clients
)
}
func
(
g
*
Group
)
GetClients
(
except
Client
)
[]
Client
{
...
...
@@ -565,7 +587,7 @@ func (g *Group) Range(f func(c Client) bool) {
}
}
func
(
g
*
Group
)
Shutdown
(
message
string
)
{
func
kickall
(
g
*
Group
,
message
string
)
{
g
.
Range
(
func
(
c
Client
)
bool
{
cc
,
ok
:=
c
.
(
Kickable
)
if
ok
{
...
...
@@ -575,6 +597,10 @@ func (g *Group) Shutdown(message string) {
})
}
func
(
g
*
Group
)
Shutdown
(
message
string
)
{
kickall
(
g
,
message
)
}
type
warner
interface
{
Warn
(
oponly
bool
,
message
string
)
error
}
...
...
@@ -687,6 +713,7 @@ type description struct {
AllowRecording
bool
`json:"allow-recording,omitempty"`
AllowSubgroups
bool
`json:"allow-subgroups,omitempty"`
Autolock
bool
`json:"autolock,omitempty"`
Autokick
bool
`json:"autokick,omitempty"`
Op
[]
ClientCredentials
`json:"op,omitempty"`
Presenter
[]
ClientCredentials
`json:"presenter,omitempty"`
Other
[]
ClientCredentials
`json:"other,omitempty"`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment