Skip to content

Commit

Permalink
NK-600 Add notificationsList runtime function (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesposito authored Oct 21, 2024
1 parent 3cdf52b commit f48ddb5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 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
27 changes: 22 additions & 5 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 @@ -2633,7 +2633,8 @@ declare namespace nkruntime {
/**
* Notification Object
*/
export interface NotificationApi {
export interface ApiNotification {
id: string;
code: number;
content: {[key: string]: any};
persistent: boolean;
Expand All @@ -2643,11 +2644,12 @@ declare namespace nkruntime {
}

export interface Notification {
id: string;
code: number;
content: {[key: string]: any};
persistent: boolean;
senderId: string;
userId: string;
senderId: string;
subject: string;
createTime: number;
}
Expand All @@ -2666,11 +2668,16 @@ declare namespace nkruntime {
userId: string;
}

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

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

/**
* Wallet Update
*/
Expand Down Expand Up @@ -4123,6 +4130,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 f48ddb5

Please sign in to comment.