github.com/vnforks/kid/v5@v5.22.1-0.20200408055009-b89d99c65676/app/user_terms_of_service.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package app
     5  
     6  import "github.com/vnforks/kid/v5/model"
     7  
     8  func (a *App) GetUserTermsOfService(userId string) (*model.UserTermsOfService, *model.AppError) {
     9  	return a.Srv().Store.UserTermsOfService().GetByUser(userId)
    10  }
    11  
    12  func (a *App) SaveUserTermsOfService(userId, termsOfServiceId string, accepted bool) *model.AppError {
    13  	if accepted {
    14  		userTermsOfService := &model.UserTermsOfService{
    15  			UserId:           userId,
    16  			TermsOfServiceId: termsOfServiceId,
    17  		}
    18  
    19  		if _, err := a.Srv().Store.UserTermsOfService().Save(userTermsOfService); err != nil {
    20  			return err
    21  		}
    22  	} else {
    23  		if err := a.Srv().Store.UserTermsOfService().Delete(userId, termsOfServiceId); err != nil {
    24  			return err
    25  		}
    26  	}
    27  
    28  	return nil
    29  }