Skip to content

Commit c70d66a

Browse files
committed
fix: timestamp type to number
1 parent 4e5bacb commit c70d66a

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

packages/restapi/src/lib/pushstream/DataModifier.ts

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
VideoEventType,
2424
MessageOrigin,
2525
VideoEvent,
26+
GroupEventBase
2627
} from './pushStreamTypes';
2728
import { VideoCallStatus, VideoPeerInfo } from '../types';
2829
import { VideoDataType } from '../video';
@@ -57,7 +58,7 @@ export class DataModifier {
5758
): JoinGroupEvent {
5859
const baseEventData: JoinGroupEvent = {
5960
origin: data.messageOrigin,
60-
timestamp: data.timestamp.toString(),
61+
timestamp: data.timestamp,
6162
chatId: data.chatId,
6263
from: data.from,
6364
to: data.to,
@@ -78,7 +79,7 @@ export class DataModifier {
7879
): LeaveGroupEvent {
7980
const baseEventData: LeaveGroupEvent = {
8081
origin: data.messageOrigin,
81-
timestamp: data.timestamp.toString(),
82+
timestamp: data.timestamp,
8283
chatId: data.chatId,
8384
from: data.from,
8485
to: data.to,
@@ -96,7 +97,7 @@ export class DataModifier {
9697
private static mapToRequestEvent(data: any, includeRaw: boolean): any {
9798
const eventData: RequestEvent = {
9899
origin: data.messageOrigin,
99-
timestamp: data.timestamp.toString(),
100+
timestamp: data.timestamp,
100101
chatId: data.chatId,
101102
from: data.from,
102103
to: data.to,
@@ -116,7 +117,7 @@ export class DataModifier {
116117
// Whatever the structure of your RemoveEvent, modify accordingly
117118
const eventData: RemoveEvent = {
118119
origin: data.messageOrigin,
119-
timestamp: data.timestamp.toString(),
120+
timestamp: data.timestamp,
120121
chatId: data.chatId,
121122
from: data.from,
122123
to: data.to,
@@ -133,7 +134,7 @@ export class DataModifier {
133134
// Whatever the structure of your RemoveEvent, modify accordingly
134135
const eventData: RoleEvent = {
135136
origin: data.messageOrigin,
136-
timestamp: data.timestamp.toString(),
137+
timestamp: data.timestamp,
137138
chatId: data.chatId,
138139
from: data.from,
139140
to: data.to,
@@ -183,10 +184,10 @@ export class DataModifier {
183184
includeRaw
184185
);
185186

186-
const groupEvent: any = {
187+
const groupEvent: GroupEventBase = {
187188
event: eventType,
188189
origin: incomingData.messageOrigin,
189-
timestamp: incomingData.timestamp.toString(),
190+
timestamp: incomingData.timestamp,
190191
chatId: incomingData.chatId,
191192
from: incomingData.from,
192193
meta,
@@ -233,7 +234,7 @@ export class DataModifier {
233234
const messageEvent: MessageEvent = {
234235
event: eventType,
235236
origin: data.messageOrigin,
236-
timestamp: data.timestamp.toString(),
237+
timestamp: data.timestamp,
237238
chatId: data.chatId, // TODO: ChatId not working for w2w
238239
from: data.fromCAIP10,
239240
to: [data.toCAIP10], // TODO: Assuming 'to' is an array in MessageEvent. Update as necessary.
@@ -330,7 +331,7 @@ export class DataModifier {
330331
const notificationEvent: NotificationEvent = {
331332
event: notificationEventType,
332333
origin: origin,
333-
timestamp: data.epoch.toString(),
334+
timestamp: data.epoch,
334335
from: data.sender,
335336
to: recipients,
336337
notifID: data.payload_id.toString(),
@@ -496,7 +497,7 @@ export class DataModifier {
496497
type BaseEventData = {
497498
event: string;
498499
origin: string;
499-
timestamp: string;
500+
timestamp: number;
500501
spaceId: string;
501502
from: string;
502503
meta: {
@@ -515,7 +516,7 @@ export class DataModifier {
515516
const baseEventData: BaseEventData = {
516517
event: data.eventType,
517518
origin: data.messageOrigin,
518-
timestamp: data.timestamp.toString(),
519+
timestamp: data.timestamp,
519520
spaceId: data.spaceId,
520521
from: data.spaceCreator,
521522
meta: {
@@ -541,7 +542,7 @@ export class DataModifier {
541542
type BaseEventData = {
542543
event: string;
543544
origin: string;
544-
timestamp: string;
545+
timestamp: number;
545546
spaceId: string;
546547
from: string;
547548
meta: {
@@ -560,7 +561,7 @@ export class DataModifier {
560561
const baseEventData: BaseEventData = {
561562
event: data.eventType,
562563
origin: data.messageOrigin,
563-
timestamp: data.timestamp.toString(),
564+
timestamp: data.timestamp,
564565
spaceId: data.spaceId,
565566
from: data.spaceCreator,
566567
meta: {
@@ -585,7 +586,7 @@ export class DataModifier {
585586
private static mapToRequestSpaceEvent(data: any, includeRaw: boolean): any {
586587
const eventData: SpaceRequestEvent = {
587588
origin: data.messageOrigin,
588-
timestamp: data.timestamp.toString(),
589+
timestamp: data.timestamp,
589590
spaceId: data.spaceId,
590591
from: data.from,
591592
to: data.to,
@@ -602,7 +603,7 @@ export class DataModifier {
602603
type BaseEventData = {
603604
event: string;
604605
origin: string;
605-
timestamp: any;
606+
timestamp: number;
606607
spaceId: any;
607608
from: any;
608609
to: any[];
@@ -614,7 +615,7 @@ export class DataModifier {
614615
const baseEventData: BaseEventData = {
615616
event: 'request',
616617
origin: data.messageOrigin === 'other' ? 'self' : 'other',
617-
timestamp: data.timestamp.toString(),
618+
timestamp: data.timestamp,
618619
spaceId: data.chatId,
619620
from: data.fromCAIP10,
620621
to: [data.toCAIP10],
@@ -633,7 +634,7 @@ export class DataModifier {
633634
type BaseEventData = {
634635
event: string;
635636
origin: string;
636-
timestamp: string;
637+
timestamp: number;
637638
spaceId: string;
638639
from: string;
639640
to: null;
@@ -645,7 +646,7 @@ export class DataModifier {
645646
const baseEventData: BaseEventData = {
646647
event: 'reject',
647648
origin: data.messageOrigin === 'other' ? 'other' : 'self',
648-
timestamp: data.timestamp.toString(),
649+
timestamp: data.timestamp,
649650
spaceId: data.chatId,
650651
from: data.fromCAIP10,
651652
to: null,
@@ -664,7 +665,7 @@ export class DataModifier {
664665
type BaseEventData = {
665666
event: string;
666667
origin: string;
667-
timestamp: string;
668+
timestamp: number;
668669
spaceId: string;
669670
from: string;
670671
to: null;
@@ -675,7 +676,7 @@ export class DataModifier {
675676

676677
const eventData: BaseEventData = {
677678
origin: data.messageOrigin,
678-
timestamp: data.timestamp.toString(),
679+
timestamp: data.timestamp,
679680
spaceId: data.spaceId,
680681
from: data.from,
681682
to: data.to,
@@ -692,7 +693,7 @@ export class DataModifier {
692693
type BaseEventData = {
693694
event: string;
694695
origin: string;
695-
timestamp: string;
696+
timestamp: number;
696697
spaceId: string;
697698
from: string;
698699
to: null;
@@ -703,7 +704,7 @@ export class DataModifier {
703704

704705
const eventData: BaseEventData = {
705706
origin: data.messageOrigin,
706-
timestamp: data.timestamp.toString(),
707+
timestamp: data.timestamp,
707708
spaceId: data.spaceId,
708709
from: data.from,
709710
to: data.to,
@@ -720,7 +721,7 @@ export class DataModifier {
720721
type BaseEventData = {
721722
event: string;
722723
origin: string;
723-
timestamp: string;
724+
timestamp: number;
724725
spaceId: string;
725726
from: string;
726727
to: null;
@@ -731,7 +732,7 @@ export class DataModifier {
731732

732733
const eventData: BaseEventData = {
733734
origin: data.messageOrigin,
734-
timestamp: data.timestamp.toString(),
735+
timestamp: data.timestamp,
735736
spaceId: data.spaceId,
736737
from: data.from,
737738
to: data.to,
@@ -748,7 +749,7 @@ export class DataModifier {
748749
type BaseEventData = {
749750
event: string;
750751
origin: string;
751-
timestamp: string;
752+
timestamp: number;
752753
spaceId: string;
753754
from: string;
754755
to: null;
@@ -759,7 +760,7 @@ export class DataModifier {
759760

760761
const eventData: BaseEventData = {
761762
origin: data.messageOrigin,
762-
timestamp: data.timestamp.toString(),
763+
timestamp: data.timestamp,
763764
spaceId: data.spaceId,
764765
from: data.from,
765766
to: null,
@@ -776,7 +777,7 @@ export class DataModifier {
776777
type BaseEventData = {
777778
event: string;
778779
origin: string;
779-
timestamp: string;
780+
timestamp: number;
780781
spaceId: string;
781782
from: string;
782783
to: null;
@@ -787,7 +788,7 @@ export class DataModifier {
787788

788789
const eventData: BaseEventData = {
789790
origin: data.messageOrigin,
790-
timestamp: data.timestamp.toString(),
791+
timestamp: data.timestamp,
791792
spaceId: data.spaceId,
792793
from: data.from,
793794
to: null,
@@ -856,7 +857,7 @@ export class DataModifier {
856857
const videoEvent: VideoEvent = {
857858
event: videoEventType,
858859
origin: origin,
859-
timestamp: data.epoch.toString(),
860+
timestamp: data.epoch,
860861
peerInfo,
861862
};
862863

packages/restapi/src/lib/pushstream/pushStreamTypes.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export interface GroupEventRawData {
132132

133133
export interface GroupEventBase {
134134
origin: MessageOrigin;
135-
timestamp: string;
135+
timestamp: number
136136
chatId: string;
137137
from: string;
138138
meta: GroupMeta;
@@ -151,7 +151,7 @@ export interface UpdateGroupEvent extends GroupEventBase {
151151
export interface GroupMemberEventBase {
152152
event: GroupEventType | MessageEventType;
153153
origin: MessageOrigin;
154-
timestamp: string;
154+
timestamp: number
155155
chatId: string;
156156
from: string;
157157
to: string[];
@@ -185,7 +185,7 @@ export interface RoleEvent extends GroupMemberEventBase {
185185
export interface SpaceMemberEventBase {
186186
event: SpaceEventType | MessageEventType;
187187
origin: MessageOrigin;
188-
timestamp: string;
188+
timestamp: number
189189
spaceId: string;
190190
from: string;
191191
to: string[];
@@ -211,7 +211,7 @@ export interface SpaceRemoveEvent extends SpaceMemberEventBase {
211211
export interface MessageEvent {
212212
event: MessageEventType;
213213
origin: MessageOrigin;
214-
timestamp: string;
214+
timestamp: number
215215
chatId: string;
216216
from: string;
217217
to: string[];
@@ -239,7 +239,7 @@ export type NotificationType = keyof typeof NOTIFICATION.TYPE;
239239
export interface NotificationEvent {
240240
event: NotificationEventType;
241241
origin: 'other' | 'self';
242-
timestamp: string;
242+
timestamp: number
243243
from: string;
244244
to: string[];
245245
notifID: string;
@@ -298,7 +298,7 @@ export interface MessageRawData {
298298
export interface VideoEvent {
299299
event: VideoEventType;
300300
origin: MessageOrigin;
301-
timestamp: string;
301+
timestamp: number
302302
peerInfo: VideoPeerInfo;
303303
raw?: GroupEventRawData;
304304
}

0 commit comments

Comments
 (0)