mirror of
https://github.com/jech/galene.git
synced 2024-12-22 15:25:48 +01:00
Implement message for locked groups.
This commit is contained in:
parent
e824b93584
commit
f8ae908d7a
5 changed files with 25 additions and 11 deletions
2
README
2
README
|
@ -114,7 +114,7 @@ The following commands are only available to users with operator
|
|||
privileges:
|
||||
|
||||
- `/clear`: clears the chat history for all users;
|
||||
- `/lock`: prevents any new users from connecting to the group unless
|
||||
- `/lock message`: prevents any new users from connecting to the group unless
|
||||
they have operator privileges;
|
||||
- `/unlock`: reverts the effect of `/lock`;
|
||||
- `/record`: start recording;
|
||||
|
|
|
@ -78,7 +78,7 @@ type Group struct {
|
|||
description *groupDescription
|
||||
// indicates that the group no longer exists, but it still has clients
|
||||
dead bool
|
||||
locked bool
|
||||
locked *string
|
||||
clients map[string]Client
|
||||
history []ChatHistoryEntry
|
||||
}
|
||||
|
@ -87,16 +87,24 @@ func (g *Group) Name() string {
|
|||
return g.name
|
||||
}
|
||||
|
||||
func (g *Group) Locked() bool {
|
||||
func (g *Group) Locked() (bool, string) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
return g.locked
|
||||
if(g.locked != nil) {
|
||||
return true, *g.locked
|
||||
} else {
|
||||
return false, ""
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Group) SetLocked(locked bool) {
|
||||
func (g *Group) SetLocked(locked bool, message string) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
g.locked = locked
|
||||
if locked {
|
||||
g.locked = &message
|
||||
} else {
|
||||
g.locked = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Group) Public() bool {
|
||||
|
@ -272,8 +280,12 @@ func AddClient(name string, c Client) (*Group, error) {
|
|||
|
||||
c.SetPermissions(perms)
|
||||
|
||||
if !perms.Op && g.locked {
|
||||
return nil, UserError("group is locked")
|
||||
if !perms.Op && g.locked != nil {
|
||||
m := *g.locked
|
||||
if m == "" {
|
||||
m = "group is locked"
|
||||
}
|
||||
return nil, UserError(m)
|
||||
}
|
||||
|
||||
if !perms.Op && g.description.MaxClients > 0 {
|
||||
|
|
|
@ -1008,7 +1008,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
|||
if !c.permissions.Op {
|
||||
return c.error(group.UserError("not authorised"))
|
||||
}
|
||||
c.group.SetLocked(m.Kind == "lock")
|
||||
c.group.SetLocked(m.Kind == "lock", m.Value)
|
||||
case "record":
|
||||
if !c.permissions.Record {
|
||||
return c.error(group.UserError("not authorised"))
|
||||
|
|
|
@ -419,11 +419,13 @@ ServerConnection.prototype.chat = function(username, kind, message) {
|
|||
*
|
||||
* @param {string} kind - One of "clearchat", "lock", "unlock", "record or
|
||||
* "unrecord".
|
||||
* @param {string} [message]
|
||||
*/
|
||||
ServerConnection.prototype.groupAction = function(kind) {
|
||||
ServerConnection.prototype.groupAction = function(kind, message) {
|
||||
this.send({
|
||||
type: 'groupaction',
|
||||
kind: kind,
|
||||
value: message,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1072,7 +1072,7 @@ function handleInput() {
|
|||
displayError("You're not an operator");
|
||||
return;
|
||||
}
|
||||
serverConnection.groupAction(cmd.slice(1));
|
||||
serverConnection.groupAction(cmd.slice(1), rest);
|
||||
return;
|
||||
case '/record':
|
||||
case '/unrecord':
|
||||
|
|
Loading…
Reference in a new issue