Skip to content
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

[GH-178] Assign moderator to only the user who start the meeting #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ type EnrichMeetingJwtRequest struct {
// Claims extents cristalhq/jwt standard claims to add jitsi-web-token specific fields
type Claims struct {
jwt.StandardClaims
Context Context `json:"context"`
Room string `json:"room,omitempty"`
Context Context `json:"context"`
Room string `json:"room,omitempty"`
Moderator bool `json:"moderator,omitempty"` // only the user started the meeting is moderator
CreatorID string `json:"creator_id,omitempty"` // store id of user who start the meeting
}

func verifyJwt(secret string, jwtToken string) (*Claims, error) {
Expand Down Expand Up @@ -200,6 +202,7 @@ func (p *Plugin) updateJwtUserInfo(jwtToken string, user *model.User) (string, e
}

claims.Context = newContext
claims.Moderator = sanitizedUser.Id == claims.CreatorID

return signClaims(secret, claims)
}
Expand Down Expand Up @@ -280,6 +283,8 @@ func (p *Plugin) startMeeting(user *model.User, channel *model.Channel, meetingI
claims.ExpiresAt = jwt.NewNumericDate(meetingLinkValidUntil)
claims.Subject = jURL.Hostname()
claims.Room = meetingID
claims.Moderator = false
claims.CreatorID = user.Id

var err2 error
jwtToken, err2 = signClaims(p.getConfiguration().JitsiAppSecret, &claims)
Expand Down
1 change: 1 addition & 0 deletions server/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestSignClaims(t *testing.T) {
claims.ExpiresAt = jwt.NewNumericDate(time.Time{})
claims.Subject = "test"
claims.Room = "test"
claims.Moderator = true

token, err := signClaims("test-secret", &claims)
require.Nil(t, err)
Expand Down
12 changes: 10 additions & 2 deletions webapp/src/components/root_portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ type Props = {
children: React.ReactNode,
}

export class InjectionProvider extends React.Component<any> {
public render(): JSX.Element {
const stores = {...this.props};
delete stores.children;
return React.createElement(Provider as any, stores, this.props.children);
}
}
Comment on lines +15 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixes this one

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there should be a cleaner solution for a lint issue like this 🤷 Any thoughts on how this change may introduce a bug? Was this solution sourced from somewhere on the web?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the solution here mobxjs/mobx-react#342 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jespino Curious what you think about this. Probably insignificant


export default class RootPortal {
el: HTMLElement;
store: any;
Expand All @@ -38,11 +46,11 @@ export default class RootPortal {
const rootPortal = document.getElementById('root-portal');
if (rootPortal) {
ReactDOM.render((
<Provider store={this.store}>
<InjectionProvider store={this.store}>
<I18nProvider>
<Conference/>
</I18nProvider>
</Provider>
</InjectionProvider>
), this.el);
}
}
Expand Down