Skip to content

Commit

Permalink
feat:News alerts (#219)
Browse files Browse the repository at this point in the history
* implemented all news alert apis

* fixed duplicate file

* regen

* fixed a typo

* removed the now obsolete newsAlerts apis

* added context

* fixed a mistake during rebasing
  • Loading branch information
CommanderStorm authored Oct 1, 2023
1 parent d10d13a commit 6bdc697
Show file tree
Hide file tree
Showing 9 changed files with 1,338 additions and 1,228 deletions.
2,087 changes: 1,083 additions & 1,004 deletions server/api/tumdev/campus_backend.pb.go

Large diffs are not rendered by default.

59 changes: 43 additions & 16 deletions server/api/tumdev/campus_backend.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions server/api/tumdev/campus_backend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ option java_outer_classname = "CampusApiProto";
option java_package = "app.tum.campus.api";

service Campus {
rpc GetTopNews(GetTopNewsRequest) returns (GetTopNewsReply) {
option (google.api.http) = {get: "/news/top"};
rpc GetNewsAlerts(GetNewsAlertsRequest) returns (GetNewsAlertsReply) {
option (google.api.http) = {
get: "/news/alerts"
response_body: "alerts"
};
}

rpc GetNewsSources(GetNewsSourcesRequest) returns (GetNewsSourcesReply) {
Expand Down Expand Up @@ -264,8 +267,16 @@ message NewsSource {
string icon = 3;
}

message GetTopNewsRequest {}
message GetTopNewsReply {
message GetNewsAlertsRequest {
// the last id of the news item received. 0 to get all news items
int32 last_news_alert_id = 1;
}

message GetNewsAlertsReply {
repeated NewsAlert alerts = 1;
}

message NewsAlert {
string image_url = 1;
string link = 2;
google.protobuf.Timestamp created = 3;
Expand Down
86 changes: 56 additions & 30 deletions server/api/tumdev/campus_backend.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,17 +703,17 @@
]
}
},
"/news/sources": {
"/news/alerts": {
"get": {
"operationId": "Campus_GetNewsSources",
"operationId": "Campus_GetNewsAlerts",
"responses": {
"200": {
"description": "",
"schema": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/apiNewsSource"
"$ref": "#/definitions/apiNewsAlert"
}
}
},
Expand All @@ -724,19 +724,33 @@
}
}
},
"parameters": [
{
"name": "lastNewsAlertId",
"description": "the last id of the news item received. 0 to get all news items",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
}
],
"tags": [
"Campus"
]
}
},
"/news/top": {
"/news/sources": {
"get": {
"operationId": "Campus_GetTopNews",
"operationId": "Campus_GetNewsSources",
"responses": {
"200": {
"description": "A successful response.",
"description": "",
"schema": {
"$ref": "#/definitions/apiGetTopNewsReply"
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/apiNewsSource"
}
}
},
"default": {
Expand Down Expand Up @@ -1272,6 +1286,18 @@
}
}
},
"apiGetNewsAlertsReply": {
"type": "object",
"properties": {
"alerts": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/apiNewsAlert"
}
}
}
},
"apiGetNewsReply": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1362,29 +1388,6 @@
}
}
},
"apiGetTopNewsReply": {
"type": "object",
"properties": {
"imageUrl": {
"type": "string"
},
"link": {
"type": "string"
},
"created": {
"type": "string",
"format": "date-time"
},
"from": {
"type": "string",
"format": "date-time"
},
"to": {
"type": "string",
"format": "date-time"
}
}
},
"apiGetUpdateNoteReply": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1594,6 +1597,29 @@
}
}
},
"apiNewsAlert": {
"type": "object",
"properties": {
"imageUrl": {
"type": "string"
},
"link": {
"type": "string"
},
"created": {
"type": "string",
"format": "date-time"
},
"from": {
"type": "string",
"format": "date-time"
},
"to": {
"type": "string",
"format": "date-time"
}
}
},
"apiNewsSource": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 6bdc697

Please sign in to comment.