diff --git a/CHANGELOG.md b/CHANGELOG.md index fc4c76d..0982f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/index.d.ts b/index.d.ts index cd9c87c..54805d0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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. * @@ -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. * @@ -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 } @@ -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. */ diff --git a/runtime/runtime.go b/runtime/runtime.go index c2d6672..fb4900c 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -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 @@ -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 @@ -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 }