Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/fix-weekly-rotation-notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@audius/sdk': patch
---

Parse weekly rotation notifications so a response containing one does not fail to load the entire notification list.
18 changes: 9 additions & 9 deletions packages/common/src/adapters/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,15 @@ export const notificationFromSDK = (
...formatBaseNotification(notification)
}
}
case 'weekly_rotation': {
const data = notification.actions[0].data
return {
type: NotificationType.WeeklyRotation,
year: data.year,
week: data.week,
...formatBaseNotification(notification)
}
}
case 'fan_remix_contest_ended': {
const data = notification.actions[0].data
return {
Expand Down Expand Up @@ -688,15 +697,6 @@ export const notificationFromSDK = (
type: string
actions: typeof notification.actions
}
if (n.type === 'weekly_rotation') {
const data = n.actions[0].data as unknown as Record<string, number>
return {
type: NotificationType.WeeklyRotation,
year: data.year,
week: data.week,
...formatBaseNotification(notification)
}
}
if (n.type === 'remix_contest_update') {
const data = n.actions[0].data as unknown as Record<string, string>
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const GetNotificationsTypesEnum = {
CommentMention: 'comment_mention',
CommentReaction: 'comment_reaction',
ListenStreakReminder: 'listen_streak_reminder',
WeeklyRotation: 'weekly_rotation',
FanRemixContestStarted: 'fan_remix_contest_started',
FanRemixContestEnded: 'fan_remix_contest_ended',
FanRemixContestEndingSoon: 'fan_remix_contest_ending_soon',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,20 @@ import {
UsdcPurchaseSellerNotificationFromJSONTyped,
UsdcPurchaseSellerNotificationToJSON,
} from './UsdcPurchaseSellerNotification';
import {
WeeklyRotationNotification,
instanceOfWeeklyRotationNotification,
WeeklyRotationNotificationFromJSON,
WeeklyRotationNotificationFromJSONTyped,
WeeklyRotationNotificationToJSON,
} from './WeeklyRotationNotification';

/**
* @type Notification
*
* @export
*/
export type Notification = { type: 'announcement' } & AnnouncementNotification | { type: 'approve_manager_request' } & ApproveManagerRequestNotification | { type: 'artist_remix_contest_ended' } & ArtistRemixContestEndedNotification | { type: 'artist_remix_contest_ending_soon' } & ArtistRemixContestEndingSoonNotification | { type: 'artist_remix_contest_submissions' } & ArtistRemixContestSubmissionsNotification | { type: 'challenge_reward' } & ChallengeRewardNotification | { type: 'claimable_reward' } & ClaimableRewardNotification | { type: 'comment' } & CommentNotification | { type: 'comment_mention' } & CommentMentionNotification | { type: 'comment_reaction' } & CommentReactionNotification | { type: 'comment_thread' } & CommentThreadNotification | { type: 'cosign' } & CosignNotification | { type: 'create' } & CreateNotification | { type: 'fan_club_text_post' } & FanClubTextPostNotification | { type: 'fan_remix_contest_ended' } & FanRemixContestEndedNotification | { type: 'fan_remix_contest_ending_soon' } & FanRemixContestEndingSoonNotification | { type: 'fan_remix_contest_started' } & FanRemixContestStartedNotification | { type: 'fan_remix_contest_submission' } & FanRemixContestSubmissionNotification | { type: 'fan_remix_contest_winners_selected' } & FanRemixContestWinnersSelectedNotification | { type: 'follow' } & FollowNotification | { type: 'listen_streak_reminder' } & ListenStreakReminderNotification | { type: 'milestone' } & MilestoneNotification | { type: 'reaction' } & ReactionNotification | { type: 'remix' } & RemixNotification | { type: 'remix_contest_update' } & RemixContestUpdateNotification | { type: 'repost' } & RepostNotification | { type: 'repost_of_repost' } & RepostOfRepostNotification | { type: 'request_manager' } & RequestManagerNotification | { type: 'save' } & SaveNotification | { type: 'save_of_repost' } & SaveOfRepostNotification | { type: 'supporter_dethroned' } & SupporterDethronedNotification | { type: 'supporter_rank_up' } & SupporterRankUpNotification | { type: 'supporting_rank_up' } & SupporterRankUpNotification | { type: 'tastemaker' } & TastemakerNotification | { type: 'tier_change' } & TierChangeNotification | { type: 'tip_receive' } & ReceiveTipNotification | { type: 'tip_send' } & SendTipNotification | { type: 'track_added_to_playlist' } & TrackAddedToPlaylistNotification | { type: 'track_added_to_purchased_album' } & TrackAddedToPurchasedAlbumNotification | { type: 'track_collaborator_accept' } & TrackCollaboratorNotification | { type: 'track_collaborator_invite' } & TrackCollaboratorNotification | { type: 'trending' } & TrendingNotification | { type: 'trending_playlist' } & TrendingPlaylistNotification | { type: 'trending_underground' } & TrendingUndergroundNotification | { type: 'usdc_purchase_buyer' } & UsdcPurchaseBuyerNotification | { type: 'usdc_purchase_seller' } & UsdcPurchaseSellerNotification;
export type Notification = { type: 'announcement' } & AnnouncementNotification | { type: 'approve_manager_request' } & ApproveManagerRequestNotification | { type: 'artist_remix_contest_ended' } & ArtistRemixContestEndedNotification | { type: 'artist_remix_contest_ending_soon' } & ArtistRemixContestEndingSoonNotification | { type: 'artist_remix_contest_submissions' } & ArtistRemixContestSubmissionsNotification | { type: 'challenge_reward' } & ChallengeRewardNotification | { type: 'claimable_reward' } & ClaimableRewardNotification | { type: 'comment' } & CommentNotification | { type: 'comment_mention' } & CommentMentionNotification | { type: 'comment_reaction' } & CommentReactionNotification | { type: 'comment_thread' } & CommentThreadNotification | { type: 'cosign' } & CosignNotification | { type: 'create' } & CreateNotification | { type: 'fan_club_text_post' } & FanClubTextPostNotification | { type: 'fan_remix_contest_ended' } & FanRemixContestEndedNotification | { type: 'fan_remix_contest_ending_soon' } & FanRemixContestEndingSoonNotification | { type: 'fan_remix_contest_started' } & FanRemixContestStartedNotification | { type: 'fan_remix_contest_submission' } & FanRemixContestSubmissionNotification | { type: 'fan_remix_contest_winners_selected' } & FanRemixContestWinnersSelectedNotification | { type: 'follow' } & FollowNotification | { type: 'listen_streak_reminder' } & ListenStreakReminderNotification | { type: 'milestone' } & MilestoneNotification | { type: 'reaction' } & ReactionNotification | { type: 'remix' } & RemixNotification | { type: 'remix_contest_update' } & RemixContestUpdateNotification | { type: 'repost' } & RepostNotification | { type: 'repost_of_repost' } & RepostOfRepostNotification | { type: 'request_manager' } & RequestManagerNotification | { type: 'save' } & SaveNotification | { type: 'save_of_repost' } & SaveOfRepostNotification | { type: 'supporter_dethroned' } & SupporterDethronedNotification | { type: 'supporter_rank_up' } & SupporterRankUpNotification | { type: 'supporting_rank_up' } & SupporterRankUpNotification | { type: 'tastemaker' } & TastemakerNotification | { type: 'tier_change' } & TierChangeNotification | { type: 'tip_receive' } & ReceiveTipNotification | { type: 'tip_send' } & SendTipNotification | { type: 'track_added_to_playlist' } & TrackAddedToPlaylistNotification | { type: 'track_added_to_purchased_album' } & TrackAddedToPurchasedAlbumNotification | { type: 'track_collaborator_accept' } & TrackCollaboratorNotification | { type: 'track_collaborator_invite' } & TrackCollaboratorNotification | { type: 'trending' } & TrendingNotification | { type: 'trending_playlist' } & TrendingPlaylistNotification | { type: 'trending_underground' } & TrendingUndergroundNotification | { type: 'usdc_purchase_buyer' } & UsdcPurchaseBuyerNotification | { type: 'usdc_purchase_seller' } & UsdcPurchaseSellerNotification | { type: 'weekly_rotation' } & WeeklyRotationNotification;

export function NotificationFromJSON(json: any): Notification {
return NotificationFromJSONTyped(json, false);
Expand Down Expand Up @@ -429,6 +436,8 @@ export function NotificationFromJSONTyped(json: any, ignoreDiscriminator: boolea
return {...UsdcPurchaseBuyerNotificationFromJSONTyped(json, true), type: 'usdc_purchase_buyer'};
case 'usdc_purchase_seller':
return {...UsdcPurchaseSellerNotificationFromJSONTyped(json, true), type: 'usdc_purchase_seller'};
case 'weekly_rotation':
return {...WeeklyRotationNotificationFromJSONTyped(json, true), type: 'weekly_rotation'};
default:
throw new Error(`No variant of Notification exists with 'type=${json['type']}'`);
}
Expand Down Expand Up @@ -534,6 +543,8 @@ export function NotificationToJSON(value?: Notification | null): any {
return UsdcPurchaseBuyerNotificationToJSON(value);
case 'usdc_purchase_seller':
return UsdcPurchaseSellerNotificationToJSON(value);
case 'weekly_rotation':
return WeeklyRotationNotificationToJSON(value);
default:
throw new Error(`No variant of Notification exists with 'type=${value['type']}'`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
/**
* Audius API
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
import type { WeeklyRotationNotificationAction } from './WeeklyRotationNotificationAction';
import {
WeeklyRotationNotificationActionFromJSON,
WeeklyRotationNotificationActionFromJSONTyped,
WeeklyRotationNotificationActionToJSON,
} from './WeeklyRotationNotificationAction';

/**
*
* @export
* @interface WeeklyRotationNotification
*/
export interface WeeklyRotationNotification {
/**
*
* @type {string}
* @memberof WeeklyRotationNotification
*/
type: string;
/**
*
* @type {string}
* @memberof WeeklyRotationNotification
*/
groupId: string;
/**
*
* @type {boolean}
* @memberof WeeklyRotationNotification
*/
isSeen: boolean;
/**
*
* @type {number}
* @memberof WeeklyRotationNotification
*/
seenAt?: number;
/**
*
* @type {Array<WeeklyRotationNotificationAction>}
* @memberof WeeklyRotationNotification
*/
actions: Array<WeeklyRotationNotificationAction>;
}

/**
* Check if a given object implements the WeeklyRotationNotification interface.
*/
export function instanceOfWeeklyRotationNotification(value: object): value is WeeklyRotationNotification {
let isInstance = true;
isInstance = isInstance && "type" in value && value["type"] !== undefined;
isInstance = isInstance && "groupId" in value && value["groupId"] !== undefined;
isInstance = isInstance && "isSeen" in value && value["isSeen"] !== undefined;
isInstance = isInstance && "actions" in value && value["actions"] !== undefined;

return isInstance;
}

export function WeeklyRotationNotificationFromJSON(json: any): WeeklyRotationNotification {
return WeeklyRotationNotificationFromJSONTyped(json, false);
}

export function WeeklyRotationNotificationFromJSONTyped(json: any, ignoreDiscriminator: boolean): WeeklyRotationNotification {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'type': json['type'],
'groupId': json['group_id'],
'isSeen': json['is_seen'],
'seenAt': !exists(json, 'seen_at') ? undefined : json['seen_at'],
'actions': ((json['actions'] as Array<any>).map(WeeklyRotationNotificationActionFromJSON)),
};
}

export function WeeklyRotationNotificationToJSON(value?: WeeklyRotationNotification | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'type': value.type,
'group_id': value.groupId,
'is_seen': value.isSeen,
'seen_at': value.seenAt,
'actions': ((value.actions as Array<any>).map(WeeklyRotationNotificationActionToJSON)),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
/**
* Audius API
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
import type { WeeklyRotationNotificationActionData } from './WeeklyRotationNotificationActionData';
import {
WeeklyRotationNotificationActionDataFromJSON,
WeeklyRotationNotificationActionDataFromJSONTyped,
WeeklyRotationNotificationActionDataToJSON,
} from './WeeklyRotationNotificationActionData';

/**
*
* @export
* @interface WeeklyRotationNotificationAction
*/
export interface WeeklyRotationNotificationAction {
/**
*
* @type {string}
* @memberof WeeklyRotationNotificationAction
*/
specifier: string;
/**
*
* @type {string}
* @memberof WeeklyRotationNotificationAction
*/
type: string;
/**
*
* @type {number}
* @memberof WeeklyRotationNotificationAction
*/
timestamp: number;
/**
*
* @type {WeeklyRotationNotificationActionData}
* @memberof WeeklyRotationNotificationAction
*/
data: WeeklyRotationNotificationActionData;
}

/**
* Check if a given object implements the WeeklyRotationNotificationAction interface.
*/
export function instanceOfWeeklyRotationNotificationAction(value: object): value is WeeklyRotationNotificationAction {
let isInstance = true;
isInstance = isInstance && "specifier" in value && value["specifier"] !== undefined;
isInstance = isInstance && "type" in value && value["type"] !== undefined;
isInstance = isInstance && "timestamp" in value && value["timestamp"] !== undefined;
isInstance = isInstance && "data" in value && value["data"] !== undefined;

return isInstance;
}

export function WeeklyRotationNotificationActionFromJSON(json: any): WeeklyRotationNotificationAction {
return WeeklyRotationNotificationActionFromJSONTyped(json, false);
}

export function WeeklyRotationNotificationActionFromJSONTyped(json: any, ignoreDiscriminator: boolean): WeeklyRotationNotificationAction {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'specifier': json['specifier'],
'type': json['type'],
'timestamp': json['timestamp'],
'data': WeeklyRotationNotificationActionDataFromJSON(json['data']),
};
}

export function WeeklyRotationNotificationActionToJSON(value?: WeeklyRotationNotificationAction | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'specifier': value.specifier,
'type': value.type,
'timestamp': value.timestamp,
'data': WeeklyRotationNotificationActionDataToJSON(value.data),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
/**
* Audius API
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
/**
* The rotation period being announced, as an ISO (year, week) pair; the mix itself is served by GET /v1/users/{id}/weekly-rotation.
* @export
* @interface WeeklyRotationNotificationActionData
*/
export interface WeeklyRotationNotificationActionData {
/**
*
* @type {number}
* @memberof WeeklyRotationNotificationActionData
*/
year: number;
/**
*
* @type {number}
* @memberof WeeklyRotationNotificationActionData
*/
week: number;
}

/**
* Check if a given object implements the WeeklyRotationNotificationActionData interface.
*/
export function instanceOfWeeklyRotationNotificationActionData(value: object): value is WeeklyRotationNotificationActionData {
let isInstance = true;
isInstance = isInstance && "year" in value && value["year"] !== undefined;
isInstance = isInstance && "week" in value && value["week"] !== undefined;

return isInstance;
}

export function WeeklyRotationNotificationActionDataFromJSON(json: any): WeeklyRotationNotificationActionData {
return WeeklyRotationNotificationActionDataFromJSONTyped(json, false);
}

export function WeeklyRotationNotificationActionDataFromJSONTyped(json: any, ignoreDiscriminator: boolean): WeeklyRotationNotificationActionData {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'year': json['year'],
'week': json['week'],
};
}

export function WeeklyRotationNotificationActionDataToJSON(value?: WeeklyRotationNotificationActionData | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'year': value.year,
'week': value.week,
};
}
3 changes: 3 additions & 0 deletions packages/sdk/src/sdk/api/generated/default/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,7 @@ export * from './UserTracksDownloadCountResponse';
export * from './UserTracksRemixedResponse';
export * from './VerifyToken';
export * from './VersionMetadata';
export * from './WeeklyRotationNotification';
export * from './WeeklyRotationNotificationAction';
export * from './WeeklyRotationNotificationActionData';
export * from './WriteResponse';
Loading
Loading