diff --git a/services/common/genproto/modules/feeds.pb.go b/services/common/genproto/modules/feeds.pb.go index 97aaa32..7dfdaf7 100644 --- a/services/common/genproto/modules/feeds.pb.go +++ b/services/common/genproto/modules/feeds.pb.go @@ -30,6 +30,7 @@ type Feed struct { Retrieved string `protobuf:"bytes,3,opt,name=retrieved,proto3" json:"retrieved,omitempty"` Created string `protobuf:"bytes,4,opt,name=created,proto3" json:"created,omitempty"` Updated string `protobuf:"bytes,5,opt,name=updated,proto3" json:"updated,omitempty"` + Deleted bool `protobuf:"varint,6,opt,name=deleted,proto3" json:"deleted,omitempty"` } func (x *Feed) Reset() { @@ -99,6 +100,13 @@ func (x *Feed) GetUpdated() string { return "" } +func (x *Feed) GetDeleted() bool { + if x != nil { + return x.Deleted + } + return false +} + type GetFeedRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -196,7 +204,7 @@ func (x *GetFeedResponse) GetFeed() *Feed { var File_feeds_proto protoreflect.FileDescriptor var file_feeds_proto_rawDesc = []byte{ - 0x0a, 0x0b, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x82, 0x01, + 0x0a, 0x0b, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x01, 0x0a, 0x04, 0x46, 0x65, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, @@ -205,18 +213,20 @@ var file_feeds_proto_rawDesc = []byte{ 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x64, 0x22, 0x20, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x22, 0x2c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x04, 0x66, 0x65, 0x65, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x46, 0x65, 0x65, 0x64, 0x52, 0x04, 0x66, 0x65, - 0x65, 0x64, 0x32, 0x3d, 0x0a, 0x0b, 0x46, 0x65, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x12, 0x0f, 0x2e, 0x47, - 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, - 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x1c, 0x5a, 0x1a, 0x68, 0x74, 0x77, 0x6b, 0x61, 0x6c, 0x65, 0x6e, 0x64, 0x65, 0x72, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x22, 0x20, 0x0a, 0x0e, + 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2c, + 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x19, 0x0a, 0x04, 0x66, 0x65, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x05, 0x2e, 0x46, 0x65, 0x65, 0x64, 0x52, 0x04, 0x66, 0x65, 0x65, 0x64, 0x32, 0x3d, 0x0a, 0x0b, + 0x46, 0x65, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x47, + 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x1c, 0x5a, 0x1a, 0x68, + 0x74, 0x77, 0x6b, 0x61, 0x6c, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/services/data-manager/service/db/dbFeeds.go b/services/data-manager/service/db/dbFeeds.go index a989873..3def9b0 100644 --- a/services/data-manager/service/db/dbFeeds.go +++ b/services/data-manager/service/db/dbFeeds.go @@ -48,6 +48,7 @@ func FindFeedByToken(app *pocketbase.PocketBase, token string) (*model.Feed, err var feed model.Feed feed.Modules = record.GetString("modules") feed.Retrieved = record.GetDateTime("retrieved") + feed.Deleted = record.GetBool("deleted") //update retrieved time if the is not marked as deleted if !record.GetBool("deleted") { diff --git a/services/data-manager/service/grpc/mapper.go b/services/data-manager/service/grpc/mapper.go index ee3ea58..4981044 100644 --- a/services/data-manager/service/grpc/mapper.go +++ b/services/data-manager/service/grpc/mapper.go @@ -39,5 +39,6 @@ func feedToProto(feed *model.Feed) *pb.Feed { Updated: feed.Updated.String(), Retrieved: feed.Retrieved.String(), Modules: feed.Modules, + Deleted: feed.Deleted, } } diff --git a/services/ical/service/connector/feedConnector.go b/services/ical/service/connector/feedConnector.go index 4b98d77..9ff12f4 100644 --- a/services/ical/service/connector/feedConnector.go +++ b/services/ical/service/connector/feedConnector.go @@ -19,6 +19,7 @@ package connector import ( "encoding/json" "errors" + "fmt" "htwkalender/ical/model" "log/slog" ) @@ -29,9 +30,9 @@ func GetFeedByToken(host string, token string) (model.FeedRecord, error) { // /api/collections/feeds/records/{id} response, err := RequestApi(host, "/api/collections/feeds/records/"+token) - if err != nil { + if err != nil || response.StatusCode() != 200 { slog.Error("Failed to get feed record", "error", err) - return model.FeedRecord{}, err + return model.FeedRecord{}, fmt.Errorf("failed to get feed record") } // parse the response body json to FeedRecord struct diff --git a/services/ical/service/connector/grpc/feeds.go b/services/ical/service/connector/grpc/feeds.go index e4ce937..a8a16f6 100644 --- a/services/ical/service/connector/grpc/feeds.go +++ b/services/ical/service/connector/grpc/feeds.go @@ -64,5 +64,6 @@ func protoToFeed(feed *pb.Feed) (model.FeedRecord, error) { }, Retrieved: model.ToJSONTime(feed.Retrieved), Modules: modules, + Deleted: feed.Deleted, }, nil } diff --git a/services/ical/service/ical/ical.go b/services/ical/service/ical/ical.go index cca09d6..7582fa6 100644 --- a/services/ical/service/ical/ical.go +++ b/services/ical/service/ical/ical.go @@ -68,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 || feedRecord.Deleted { + if err != nil { return model.FeedRecord{}, err } diff --git a/services/ical/service/routes.go b/services/ical/service/routes.go index b699deb..c92a0f7 100644 --- a/services/ical/service/routes.go +++ b/services/ical/service/routes.go @@ -79,8 +79,12 @@ func AddFeedRoutes(app model.AppType) { token := c.Params("token") results, err := ical.FeedRecord(app, token) + if results.Deleted { + return c.SendStatus(fiber.StatusNotFound) + } + if err != nil { - slog.Error("Failed to get feed", "error", err, "token", token) + slog.Error("Failed to get feed record", "error", err, "token", token) return c.SendStatus(fiber.StatusBadRequest) } c.Response().Header.Set("Content-type", "application/json; charset=UTF-8") diff --git a/services/protobuf/feeds.proto b/services/protobuf/feeds.proto index 7580cbd..243b83a 100644 --- a/services/protobuf/feeds.proto +++ b/services/protobuf/feeds.proto @@ -12,6 +12,7 @@ message Feed { string retrieved = 3; string created = 4; string updated = 5; + bool deleted = 6; } message GetFeedRequest {