Skip to content

Commit

Permalink
[NK-603] Add new runtime APIs (#162)
Browse files Browse the repository at this point in the history
Add Follow/Unfollow runtime function.
Add NotificationsUpodate runtime function.
  • Loading branch information
sesposito authored Nov 21, 2024
1 parent 13c2528 commit e24311a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
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

0 comments on commit e24311a

Please sign in to comment.