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

NK-600 Add notificationsList runtime function #160

Merged
merged 2 commits into from
Oct 21, 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
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
Loading