summaryrefslogtreecommitdiffstats
path: root/app/terms_of_service.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/terms_of_service.go')
-rw-r--r--app/terms_of_service.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/terms_of_service.go b/app/terms_of_service.go
new file mode 100644
index 000000000..9850b3450
--- /dev/null
+++ b/app/terms_of_service.go
@@ -0,0 +1,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
+ }
+}