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-603] Add new runtime APIs #162

Merged
merged 2 commits into from
Nov 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
## [Unreleased]
### Added
- Add new runtime function to get a list of user's friend status.
- Add new Follow/Unfollow runtime APIs.
- Add new NotificationsUpdate runtime API.

## [1.34.0] - 2024-10-21
### Added
Expand Down
37 changes: 35 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3944,6 +3944,24 @@ declare namespace nkruntime {
*/
unlinkSteam(userId: string, token?: string): void;

/**
* Follow users status changes on a given session.
*
* @param sessionId - User ID.
* @param userIds - Follow target userIds.
* @throws {TypeError, GoError}
*/
statusFollow(sessionId: string, userIds: string[])

/**
* Unfollow users status changes on a given session.
*
* @param sessionId - User ID.
* @param userIds - Unfollow target userIds.
* @throws {TypeError, GoError}
*/
statusUnfollow(sessionId: string, userIds: string[])

/**
* List stream presences.
*
Expand Down Expand Up @@ -4184,6 +4202,14 @@ declare namespace nkruntime {
*/
notificationsDeleteId(ids: string[], userId?: string): void;

/**
* Update multiple notifications.
*
* @param updates - Array of notification updates objects.
* @throws {TypeError, GoError}
*/
notificationsUpdate(updates: NotificationUpdate[]): void;

/**
* Update user wallet.
*
Expand Down Expand Up @@ -5056,9 +5082,9 @@ declare namespace nkruntime {

export interface SatoriEvent {
name: string
id: string
id?: string
metadata?: {[key: string]: string}
value: string
value?: string
timestamp: number
}

Expand Down Expand Up @@ -5107,6 +5133,13 @@ declare namespace nkruntime {
imageUrl: string
}

export interface NotificationUpdate {
id: string
content?: {[key: string]: any}
subject?: string
sender?: string
}

/**
* The Satori integration functions.
*/
Expand Down
11 changes: 11 additions & 0 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,13 @@ type Notification struct {
Persistent bool
}

type NotificationUpdate struct {
Id string
Subject *string
Content map[string]any
Sender *string
}

type WalletUpdate struct {
UserID string
Changeset map[string]int64
Expand Down Expand Up @@ -1110,6 +1117,7 @@ type NakamaModule interface {
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
NotificationsUpdate(ctx context.Context, updates ...NotificationUpdate) error
NotificationsDelete(ctx context.Context, notifications []*NotificationDelete) error
NotificationsGetId(ctx context.Context, userID string, ids []string) ([]*Notification, error)
NotificationsDeleteId(ctx context.Context, userID string, ids []string) error
Expand Down Expand Up @@ -1202,6 +1210,9 @@ type NakamaModule interface {
ChannelMessageRemove(ctx context.Context, channelId, messageId string, senderId, senderUsername string, persist bool) (*rtapi.ChannelMessageAck, error)
ChannelMessagesList(ctx context.Context, channelId string, limit int, forward bool, cursor string) (messages []*api.ChannelMessage, nextCursor string, prevCursor string, err error)

StatusFollow(sessionID string, userIDs []string) error
StatusUnfollow(sessionID string, userIDs []string) error

GetSatori() Satori
GetFleetManager() FleetManager
}
Expand Down
Loading