Skip to content

Commit

Permalink
Add new runtime APIs
Browse files Browse the repository at this point in the history
Add Follow/Unfollow runtime function.
Add NotificationsUpodate runtime function.
  • Loading branch information
sesposito committed Nov 7, 2024
1 parent 8c42e0a commit d835e59
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 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
- Add new Follow/Unfollow runtime APIs.
- Add new NotificationsUpdate runtime API.

## [1.34.0] - 2024-10-21
### Added
Expand Down
33 changes: 33 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3931,6 +3931,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 @@ -4171,6 +4189,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 @@ -5094,6 +5120,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 @@ -1109,6 +1116,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 @@ -1201,6 +1209,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 d835e59

Please sign in to comment.