// Copyright (C) 2019 Marius Schellenberger

package db

import (
	"git.giftfish.de/ston1th/gowiki/pkg/core"
	"git.giftfish.de/ston1th/gowiki/pkg/log"
	"git.giftfish.de/ston1th/gowiki/pkg/render"
)

func (db *DB) ReadPerm(st, username string, p core.Permission) bool {
	section, _ := render.SplitStoreTitle(st)
	s, err := db.GetSection(section)
	if err != nil {
		log.Debugf("db: read: %s", err)
		return false
	}
	return core.ReadPerm(username, p, s)
}

func (db *DB) WritePerm(st, username string, p core.Permission) bool {
	section, _ := render.SplitStoreTitle(st)
	s, err := db.GetSection(section)
	if err != nil {
		log.Debugf("db: read: %s", err)
		return false
	}
	return core.WritePerm(username, p, s)
}
