mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* #124 renamed identififers from service terms to terms of service * #124 renamed identififers from service terms to terms of service * 124 renamed ServiceTerms model to TermsOfService * 124 Renamed EnableCustomServiceTerms feature flag to EnableCustomTermsOfService * 124 Renamed EnableCustomServiceTerms feature flag to EnableCustomTermsOfService * #124 fixed formatting * #124 fixed formatting * #132 renamed table ServiceTerms to TermsOfService * #124 renamed some missed files from 'service_terms' to 'terms_of_service' * #124 removed fixed TODOs * drop migrate of ServiceTerms table, since backporting * s/ServiceTerms/TermsOfService/ in tests * s/AcceptedServiceTermsId/AcceptedTermsOfServiceId/ Change the model attribute, even though the column name will eventually be removed. * s/accepted_service_terms_id/accepted_terms_of_service_id/ to match redux * s/serviceTerms/termsOfService * rename column too, and add max size constraint * s/EnableCustomServiceTerms/EnableCustomTermsOfService
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
// 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
|
|
}
|
|
}
|