fix aggregate source discrepancy
This commit is contained in:
@@ -258,6 +258,7 @@ func (b *DBBackend) syncConfig(ctx context.Context, cfg *config.Config) error {
|
||||
for _, a := range c.Access {
|
||||
if a.ICS != "" {
|
||||
pubPath := prefix + fmt.Sprintf("/public/%s/%s.ics", c.Owner, c.ID)
|
||||
log.Printf("pp: %s", pubPath)
|
||||
b.publicAccess[pubPath] = publicInfo{
|
||||
InternalPath: path,
|
||||
Mode: a.ICS,
|
||||
@@ -768,14 +769,14 @@ func (b *DBBackend) listAggregateObjects(ctx context.Context, aggPath string, ag
|
||||
username, _ := b.getUsername(ctx)
|
||||
|
||||
for _, sourceID := range agg.Sources {
|
||||
sourcePath := b.prefix + fmt.Sprintf("/%s/calendars/%s/", agg.Owner, sourceID)
|
||||
|
||||
var calID int
|
||||
var ownerName string
|
||||
var sourcePath string
|
||||
err := b.pool.QueryRow(ctx, `
|
||||
SELECT c.id, u.name FROM calendars c
|
||||
SELECT c.id, u.name, c.path FROM calendars c
|
||||
JOIN users u ON c.owner_id = u.id
|
||||
WHERE c.path = $1`, sourcePath).Scan(&calID, &ownerName)
|
||||
WHERE c.name = $1`, sourceID).Scan(&calID, &ownerName, &sourcePath)
|
||||
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -800,7 +801,7 @@ func (b *DBBackend) listAggregateObjects(ctx context.Context, aggPath string, ag
|
||||
}
|
||||
|
||||
for _, obj := range objs {
|
||||
// Prepend source name so Diane knows this is a "[calendar]" event
|
||||
// Prepend source name so user knows this is a "[calendar]" event
|
||||
for _, child := range obj.Data.Children {
|
||||
if child.Name == "VEVENT" || child.Name == "VTODO" {
|
||||
descr := child.Props.Get("DESCRIPTION")
|
||||
@@ -831,7 +832,7 @@ func (b *DBBackend) GetCalendarObject(ctx context.Context, p string, req *caldav
|
||||
fileName := path.Base(p)
|
||||
|
||||
// Step 1: Check if this is a request for a virtual item in an aggregate
|
||||
if agg, ok := b.aggregates[dirPath]; ok {
|
||||
if _, ok := b.aggregates[dirPath]; ok {
|
||||
|
||||
hasAccess := slices.Contains(b.userAggs[username], dirPath)
|
||||
if !hasAccess {
|
||||
@@ -846,10 +847,10 @@ func (b *DBBackend) GetCalendarObject(ctx context.Context, p string, req *caldav
|
||||
sourceID := parts[0]
|
||||
realFileName := parts[1]
|
||||
|
||||
sourcePath := b.prefix + fmt.Sprintf("/%s/calendars/%s/", agg.Owner, sourceID)
|
||||
var calID int
|
||||
var ownerName string
|
||||
err := b.pool.QueryRow(ctx, "SELECT c.id, u.name FROM calendars c JOIN users u ON c.owner_id = u.id WHERE c.path = $1", sourcePath).Scan(&calID, &ownerName)
|
||||
var sourcePath string
|
||||
err := b.pool.QueryRow(ctx, "SELECT c.id, u.name, c.path FROM calendars c JOIN users u ON c.owner_id = u.id WHERE c.name = $1", sourceID).Scan(&calID, &ownerName, &sourcePath)
|
||||
if err != nil {
|
||||
return nil, webdav.NewHTTPError(http.StatusNotFound, errors.New("source calendar not found"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user