forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terms_of_service.go
45 lines (37 loc) · 1.19 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
// 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) CreateTermsOfService(text, userId string) (*model.TermsOfService, *model.AppError) {
termsOfService := &model.TermsOfService{
Text: text,
UserId: userId,
}
if _, err := a.GetUser(userId); err != nil {
return nil, err
}
result := <-a.Srv.Store.TermsOfService().Save(termsOfService)
if result.Err != nil {
return nil, result.Err
}
termsOfService = result.Data.(*model.TermsOfService)
return termsOfService, nil
}
func (a *App) GetLatestTermsOfService() (*model.TermsOfService, *model.AppError) {
if result := <-a.Srv.Store.TermsOfService().GetLatest(true); result.Err != nil {
return nil, result.Err
} else {
termsOfService := result.Data.(*model.TermsOfService)
return termsOfService, nil
}
}
func (a *App) GetTermsOfService(id string) (*model.TermsOfService, *model.AppError) {
if result := <-a.Srv.Store.TermsOfService().Get(id, true); result.Err != nil {
return nil, result.Err
} else {
termsOfService := result.Data.(*model.TermsOfService)
return termsOfService, nil
}
}