-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MM-42101] Implement option to enable calls by default #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,24 @@ func newUserSession(userID, channelID, connID string) *session { | |
|
||
func (p *Plugin) addUserSession(userID, channelID string, userSession *session) (channelState, error) { | ||
var st channelState | ||
|
||
cfg := p.getConfiguration() | ||
|
||
err := p.kvSetAtomicChannelState(channelID, func(state *channelState) (*channelState, error) { | ||
if state == nil { | ||
return nil, fmt.Errorf("channel state is missing from store") | ||
if cfg.DefaultEnabled != nil && *cfg.DefaultEnabled { | ||
state = &channelState{ | ||
Enabled: true, | ||
} | ||
} else { | ||
return nil, fmt.Errorf("channel state is missing from store") | ||
} | ||
} | ||
|
||
if !state.Enabled { | ||
return nil, fmt.Errorf("calls are not enabled") | ||
} | ||
Comment on lines
+81
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, from a server perspective it was possible to start a call on a channel with calls disabled. |
||
|
||
if state.Call == nil { | ||
state.Call = &callState{ | ||
ID: model.NewId(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,8 +112,7 @@ export default class CallsClient extends EventEmitter { | |
this.ws = ws; | ||
|
||
ws.on('error', (err) => { | ||
console.log(`ws error: ${err}`); | ||
this.ws = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was preventing the ws connection from disconnecting in case of server side error (e.g. during join). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
console.log('ws error', err); | ||
this.disconnect(); | ||
}); | ||
|
||
|
@@ -168,7 +167,7 @@ export default class CallsClient extends EventEmitter { | |
} | ||
}); | ||
peer.on('error', (err) => { | ||
console.log(`peer error: ${err}`); | ||
console.log('peer error', err); | ||
this.disconnect(); | ||
}); | ||
peer.on('stream', (remoteStream) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This essentially means we are implicitly enabling channels calls upon first call. An alternate approach was to leave it unset but that required data schema changes (converting bool to pointer to have the additional state) and it felt more convoluted overall. Happy to hear feedback though.