Skip to content

Commit

Permalink
Add notificationsList runtime function
Browse files Browse the repository at this point in the history
  • Loading branch information
sesposito committed Oct 18, 2024
1 parent 3cdf52b commit 9acdc48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org).

## [Unreleased]
### Added
- New runtime function to list user notifications.

### Fixed
- Ensure optional TypeScript context fields are marked appropriately.

Expand Down
21 changes: 18 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ declare namespace nkruntime {
* @param fn - The function to execute after ListNotifications.
* @throws {TypeError}
*/
registerAfterListNotifications(fn: AfterHookFunction<NotificationList, ListNotificationsRequest>): void;
registerAfterListNotifications(fn: AfterHookFunction<ApiNotificationList, ListNotificationsRequest>): void;

/**
* Register before Hook for RPC DeleteNotifications function.
Expand Down Expand Up @@ -2637,7 +2637,7 @@ declare namespace nkruntime {
code: number;
content: {[key: string]: any};
persistent: boolean;
senderId: string;
sender: string;
subject: string;
createTime: number;
}
Expand Down Expand Up @@ -2666,11 +2666,16 @@ declare namespace nkruntime {
userId: string;
}

export interface NotificationList {
export interface ApiNotificationList {
notifications?: NotificationApi[];
cacheableCursor?: string;
}

export interface NotificationsList {
notifications: Notification[];
cursor: string;
}

/**
* Wallet Update
*/
Expand Down Expand Up @@ -4123,6 +4128,16 @@ declare namespace nkruntime {
*/
notificationSendAll(subject: string, content: {[key: string]: any}, code: number, persistent?: boolean): void;

/**
* List notifications by user ID.
*
* @param userId - User identifier.
* @param limit - Opt. Number of notifications per result page. Must be a value between 1 and 1000. Defaults to 100.
* @param cursor - Opt. Cursor to get next page of results, if any.
* @throws {TypeError, GoError}
*/
notificationsList(userId: string, limit?: number, cursor?: string): NotificationsList;

/**
* Delete multiple notifications.
*
Expand Down
1 change: 1 addition & 0 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,7 @@ type NakamaModule interface {
MatchSignal(ctx context.Context, id string, data string) (string, error)

NotificationSend(ctx context.Context, userID, subject string, content map[string]interface{}, code int, sender string, persistent bool) error
NotificationsList(ctx context.Context, userID string, limit int, cursor string) ([]*api.Notification, string, error)
NotificationsSend(ctx context.Context, notifications []*NotificationSend) error
NotificationSendAll(ctx context.Context, subject string, content map[string]interface{}, code int, persistent bool) error
NotificationsDelete(ctx context.Context, notifications []*NotificationDelete) error
Expand Down

0 comments on commit 9acdc48

Please sign in to comment.