forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_terms_of_service.go
33 lines (27 loc) · 983 Bytes
/
user_terms_of_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import "github.com/mattermost/mattermost-server/model"
func (a *App) GetUserTermsOfService(userId string) (*model.UserTermsOfService, *model.AppError) {
if result := <-a.Srv.Store.UserTermsOfService().GetByUser(userId); result.Err != nil {
return nil, result.Err
} else {
return result.Data.(*model.UserTermsOfService), nil
}
}
func (a *App) SaveUserTermsOfService(userId, termsOfServiceId string, accepted bool) *model.AppError {
if accepted {
userTermsOfService := &model.UserTermsOfService{
UserId: userId,
TermsOfServiceId: termsOfServiceId,
}
if result := <-a.Srv.Store.UserTermsOfService().Save(userTermsOfService); result.Err != nil {
return result.Err
}
} else {
if result := <-a.Srv.Store.UserTermsOfService().Delete(userId, termsOfServiceId); result.Err != nil {
return result.Err
}
}
return nil
}