feat:#44 updated delete process and api response

This commit is contained in:
Elmar Kresse
2024-07-13 16:46:28 +02:00
parent 0addcd72a6
commit 1f9e9614aa
17 changed files with 226 additions and 15 deletions

View File

@@ -1,7 +1,24 @@
//Calendar implementation for the HTWK Leipzig timetable. Evaluation and display of the individual dates in iCal format.
//Copyright (C) 2024 HTWKalender support@htwkalender.de
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU Affero General Public License for more details.
//You should have received a copy of the GNU Affero General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
package ical
import (
"bytes"
"fmt"
"github.com/jordic/goics"
"htwkalender/ical/model"
"htwkalender/ical/service/connector"
@@ -12,6 +29,8 @@ import (
const expirationTime = 5 * time.Minute
var FeedDeletedError = fmt.Errorf("feed deleted")
func Feed(app model.AppType, token string) (string, error) {
// get feed by token
feed, err := htwkalenderGrpc.GetFeed(token, app.GrpcClient)
@@ -19,6 +38,10 @@ func Feed(app model.AppType, token string) (string, error) {
return "", err
}
if feed.Deleted {
return "", FeedDeletedError
}
var events model.Events
// Get all events for modules
@@ -45,7 +68,7 @@ func Feed(app model.AppType, token string) (string, error) {
func FeedRecord(app model.AppType, token string) (model.FeedRecord, error) {
feedRecord, err := connector.GetFeedByToken(app.DataManagerURL, token)
if err != nil {
if err != nil || feedRecord.Deleted {
return model.FeedRecord{}, err
}