Skip to content

Commit

Permalink
refact: stream unread notifications (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Dec 2, 2024
1 parent 84c12ba commit a735f32
Show file tree
Hide file tree
Showing 21 changed files with 1,381 additions and 878 deletions.
53 changes: 53 additions & 0 deletions protobufs/api/v1/notifications.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
syntax = "proto3";

package api.v1;

import "api/v1/options.proto";
import "api/v1/shared.proto";
import "api/v1/workouts.proto";

import "google/protobuf/empty.proto";

import "buf/validate/validate.proto";

service NotificationService {
rpc ListNotifications (ListNotificationsRequest) returns (ListNotificationsResponse) {
option (auth) = true;
}
rpc UnreadNotifications (UnreadNotificationsRequest) returns (stream UnreadNotificationsResponse) {
option (auth) = true;
}
}

message ListNotificationsRequest {
bool unread_only = 1;
bool mark_as_read = 2;
PaginationRequest pagination = 3 [(buf.validate.field).required = true];
}
message ListNotificationsResponse {
repeated Notification notifications = 1;
PaginationResponse pagination = 2;
}

message Notification {
message UserFollowed {
User actor = 1;
}
message WorkoutComment {
User actor = 1;
Workout workout = 2;
}

string id = 1;
// DEBT: This should be a timestamp but the client is not able to parse it.
int64 notified_at_unix = 2;
oneof type {
UserFollowed user_followed = 3;
WorkoutComment workout_comment = 4;
}
}

message UnreadNotificationsRequest {}
message UnreadNotificationsResponse {
int64 count = 1;
}
31 changes: 0 additions & 31 deletions protobufs/api/v1/users.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ service UserService {
rpc Search(SearchRequest) returns (SearchResponse) {
option (auth) = true;
}
rpc ListNotifications(ListNotificationsRequest) returns (ListNotificationsResponse) {
option (auth) = true;
}
}

message GetUserRequest {
Expand Down Expand Up @@ -73,31 +70,3 @@ message SearchResponse {
repeated User users = 1;
PaginationResponse pagination = 2;
}

message ListNotificationsRequest {
bool unread_only = 1;
bool mark_as_read = 2;
PaginationRequest pagination = 3 [(buf.validate.field).required = true];
}
message ListNotificationsResponse {
repeated Notification notifications = 1;
PaginationResponse pagination = 2;
}

message Notification {
message UserFollowed {
User actor = 1;
}
message WorkoutComment {
User actor = 1;
Workout workout = 2;
}

string id = 1;
// DEBT: This should be a timestamp but the client is not able to parse it.
int64 notified_at_unix = 2;
oneof type {
UserFollowed user_followed = 3;
WorkoutComment workout_comment = 4;
}
}
144 changes: 144 additions & 0 deletions server/pkg/pb/api/v1/apiv1connect/notifications.connect.go

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

56 changes: 13 additions & 43 deletions server/pkg/pb/api/v1/apiv1connect/users.connect.go

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

Loading

0 comments on commit a735f32

Please sign in to comment.