Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional legal filtering param in core article service #519

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions stroeer/core/v1/article.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,29 @@ option go_package = "github.com/stroeer/go-tapir/core/v1;core";
* Thus, not containing any data that is only required on detail pages.
* This lightweight representation is sometimes referred to as `Teaser`.
*
* | Field name | Type | Description |
* |----------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
* | `id` | `int64` | Unique ID of the article defined by the content management system (required). |
* | `type` | [`Type`][t] | Main content type of the article (required). See list of supported [`ContentType`][ct] |
* | `sub_type` | [`SubType`][st] | Subtype of the article. For `ARTICLE` this field holds a `sub_type`, for others like `GALLERY` it may not. |
* | `section_tree` | [`Reference`][ref] | Hierarchical section tree information of the article (required). |
* | `fields` | `map<string, string>` | Generic map containing general content and configuration information of the article (required). See [`fields`](#fields) |
* | `bodies` | `repeated` [`Body`][b] | Recursive textual body of the article to be rendered on detail pages. May be `null` for [_Teaser_](#teaser). |
* | `elements` | `repeated` [`Element`][e] | `Element`s required to render the teaser, such as `IMAGE`, `VIDEO` or `AUTHOR` |
* | `keywords` | `repeated` [`Keyword`][k] | Extracted keywords from the article body like persons, locations, organizations etc. |
* | `onwards` | `int64` | IDs of articles related to this article. Related articles are defined manually in the content management system by the editorial department. |
* | `variants` | `repeated` [`Article`][a] | Variants of this article, e.g. for headline testing. |
* | `entities` | `string` `[deprecated]` | Extracted entities from the article body like persons, locations, organizations etc. `deprecated` — use `keywords` instead. |
* | `authors` | `repeated` [`Author`][author] | Authors and|or Agencies ƒor this content |
* | `related_articles` | `repeated` [`RelatedArticle`][related_articles] | Editorial articles, which are related to the main article. Can only be an article shell with id and source in the core api.|
* | Field name | Type | Description |
* |--------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
* | `id` | `int64` | Unique ID of the article defined by the content management system (required). |
* | `type` | [`Type`][t] | Main content type of the article (required). See list of supported [`ContentType`][ct] |
* | `sub_type` | [`SubType`][st] | Subtype of the article. For `ARTICLE` this field holds a `sub_type`, for others like `GALLERY` it may not. |
* | `section_tree` | [`Reference`][ref] | Hierarchical section tree information of the article (required). |
* | `fields` | `map<string, string>` | Generic map containing general content and configuration information of the article (required). See [`fields`](#fields) |
* | `bodies` | `repeated` [`Body`][b] | Recursive textual body of the article to be rendered on detail pages. May be `null` for [_Teaser_](#teaser). |
* | `metadata` | [`Metadata`][md] | The articles [Metadata][md], containing state and various timestamps. |
* | `elements` | `repeated` [`Element`][e] | `Element`s required to render the teaser, such as `IMAGE`, `VIDEO` or `AUTHOR` |
* | `keywords` | `repeated` [`Keyword`][k] | Extracted keywords from the article body like persons, locations, organizations etc. |
* | `onwards` | `int64` | IDs of articles related to this article. Related articles are defined manually in the content management system by the editorial department. |
* | `variants` | `map<string, Article>` | Variants of this article, e.g. for headline testing. |
* | `entities` | `string` `[deprecated]` | Extracted entities from the article body like persons, locations, organizations etc. `deprecated` — use `keywords` instead. |
* | `authors` | `repeated` [`Author`][author] | Authors and or Agencies ƒor this content | |
* | `related_articles` | `repeated Article` | Editorial articles, which are related to the main article. May only be an empty unresolved article (not all services will resolve these). |
*
* [t]: #enum-type
* [b]: article_%DB%B0_body.html
* [e]: article_%DB%B0_element.html
* [k]: article_%DB%B0_keyword.html
* [st]: #enum-subtype
* [md]: article_%DB%B0_metadata.html
* [ref]: reference.html
* [author]: author.html
*
Expand Down
70 changes: 67 additions & 3 deletions stroeer/core/v1/core_article_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ option go_package = "github.com/stroeer/go-tapir/core/v1;core";
* by its id or to query multiple articles (`rpc ListArticles()`) by providing
* a query.
*
* All results returned from this service are _unfiltered_, hence they may contain
* All results returned from this service are _unfiltered_ by default, hence they may contain
* [`elements`](element.html) that are *expired*, *not yet valid* or whose [`state`](metadata.html#state)
* is not `PUBLISHED`.
* This behaviour can be changed by providing a [`RequestSettings`](#requestsettings) object.
*
* @CodeBlockStart protobuf
*/
Expand Down Expand Up @@ -51,7 +52,9 @@ service ArticleService {
*/
message GetArticleRequest {
int64 id = 1;
RequestSettings request_settings = 2;
}

/** @CodeBlockEnd */

/**
Expand All @@ -71,8 +74,8 @@ message GetArticleRequest {
*/
message BatchGetArticlesRequest {
repeated int64 ids = 1;
RequestSettings request_settings = 2;
}
/** @CodeBlockEnd */

/**
* ## BatchGetArticlesResponse
Expand Down Expand Up @@ -115,6 +118,7 @@ message ListArticlesRequest {
Filters filters = 2;
int32 page_size = 3;
string page_token = 4;
RequestSettings request_settings = 5;

/** @CodeBlockEnd */

Expand Down Expand Up @@ -223,7 +227,6 @@ message ListArticlesRequest {
/** @CodeBlockEnd */
}

// client side filters executed after the query was returned from the database
/**
* ## `Filters`
*
Expand Down Expand Up @@ -256,6 +259,67 @@ message ListArticlesRequest {
/** @CodeBlockEnd */
}

/**
* ## `RequestSettings`
*
* Alters the behavior of the request in a way that filters or alters the
* result or parts of the result based on validity of the article or its elements.
*
* You can also alter the view mode of the article, selecting either the full
* article or a limited version of it (called `teaser` or `trail`)
*
* ### `RequestSettings.ArticleViewMode`
*
* | Enum value | Description |
* |---------------------------------|------------------------------------------------------------------------------------|
* | `ARTICLE_VIEW_MODE_UNSPECIFIED` | unspecified, defaults to `ARTICLE_VIEW_MODE_DEFAULT` |
* | `ARTICLE_VIEW_MODE_DEFAULT` | full article including body and all elements. |
* | `ARTICLE_VIEW_MODE_TEASER` | elements that are not required when teasering the article are removed (e.g. body). |
*
* ### `RequestSettings.ArticleValidity`
*
* | Enum value | Description |
* |--------------------------------|-------------------------------------------------------------------------------------------|
* | `ARTICLE_VALIDITY_UNSPECIFIED` | unspecified, defaults to `ARTICLE_VALIDITY_IGNORE` |
* | `ARTICLE_VALIDITY_VALID` | filters articles that are considered valid and allowed to be accessed publicly. |
* | `ARTICLE_VALIDITY_IGNORE` | Ignore the article validity and return everything as is, even deleted or expired content. |
*
* ### `RequestSettings.ElementValidity`
*
* | Enum value | Description |
* |--------------------------------|-------------------------------------------------------------------------------------------|
* | `ELEMENT_VALIDITY_UNSPECIFIED` | unspecified, defaults to `ELEMENT_VALIDITY_IGNORE` |
* | `ELEMENT_VALIDITY_VALID` | Remove invalid elements from its parent article, such as expired images or videos. |
* | `ELEMENT_VALIDITY_IGNORE` | Ignore the element validity and return everything as is, even deleted or expired content. |
*
* @CodeBlockStart protobuf
*/
message RequestSettings {
ArticleViewMode article_view_mode = 1;
ArticleValidity article_validity = 2;
ElementValidity element_validity = 3;

enum ArticleViewMode {
ARTICLE_VIEW_MODE_UNSPECIFIED = 0;
ARTICLE_VIEW_MODE_DEFAULT = 1;
ARTICLE_VIEW_MODE_TEASER = 2;
}

enum ArticleValidity {
ARTICLE_VALIDITY_UNSPECIFIED = 0;
ARTICLE_VALIDITY_VALID = 1;
ARTICLE_VALIDITY_IGNORE = 2;
}

enum ElementValidity {
ELEMENT_VALIDITY_UNSPECIFIED = 0;
ELEMENT_VALIDITY_VALID = 1;
ELEMENT_VALIDITY_IGNORE = 2;
}
}
/** @CodeBlockEnd */


/**
* ## `ListArticlesResponse`
*
Expand Down
Loading