Skip to content

Commit 8374627

Browse files
committed
add gathering schema messages
1 parent fc5c08b commit 8374627

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

readme.ts

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export type Content =
6868
| Privatable<BlogContent>
6969
| Privatable<AliasContent>
7070
| Privatable<GatheringContent>
71+
| Privatable<GatheringUpdateContent>
72+
| Privatable<AttendeeContent>
7173
| null;
7274

7375
export interface PostContent {
@@ -136,9 +138,58 @@ export interface AliasContent {
136138
}
137139

138140
export interface GatheringContent {
139-
type: 'gathering',
140-
progenitor?: MsgId // (optional) the thing that spawned this gathering
141-
mentions?: Array<FeedId>, // (optional) people to notify
141+
type: 'gathering';
142+
143+
/**
144+
* The message that spawned this gathering
145+
*/
146+
progenitor?: MsgId;
147+
148+
/**
149+
* People to notify
150+
*/
151+
mentions?: Array<FeedId>;
152+
}
153+
154+
export interface GatheringUpdateContent {
155+
type: 'about';
156+
157+
/**
158+
* SHOULD point to a `type: 'gathering'` message.
159+
*/
160+
about: MsgId;
161+
title?: string;
162+
description?: string;
163+
location?: string;
164+
startDateTime?: {
165+
epoch?: number;
166+
ts?: string;
167+
bias?: number;
168+
silent?: boolean;
169+
};
170+
image?: {
171+
link: BlobId;
172+
name?: string;
173+
size?: number;
174+
175+
/**
176+
* mimetype
177+
*/
178+
type?: string;
179+
};
180+
}
181+
182+
export interface AttendeeContent {
183+
type: 'about';
184+
185+
/**
186+
* SHOULD point to a `type: 'gathering'` message.
187+
*/
188+
about: MsgId;
189+
attendee: {
190+
link: FeedId;
191+
remove?: true;
192+
};
142193
}
143194

144195
export interface About {

utils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
UnboxedMsg,
99
MsgId,
1010
MsgInThread,
11+
AttendeeContent,
1112
} from './readme';
1213

1314
export function isMsg(msg: any): msg is Msg<any> {
@@ -34,11 +35,11 @@ export function isPostMsg(msg: Msg<any>): msg is Msg<PostContent> {
3435
}
3536

3637
export function isRootPostMsg(msg: Msg<any>): msg is Msg<PostContent> {
37-
return isPostMsg(msg) && !msg?.value?.content?.root;
38+
return isPostMsg(msg) && !msg.value.content.root;
3839
}
3940

4041
export function isReplyPostMsg(msg: Msg<any>): msg is Msg<PostContent> {
41-
return isPostMsg(msg) && !!msg?.value?.content?.root;
42+
return isPostMsg(msg) && !!msg.value.content.root;
4243
}
4344

4445
export function isAboutMsg(msg: Msg<any>): msg is Msg<AboutContent> {
@@ -53,6 +54,15 @@ export function isVoteMsg(msg: Msg<any>): msg is Msg<VoteContent> {
5354
return msg?.value?.content?.type === 'vote';
5455
}
5556

57+
export function isAttendeeMsg(msg: Msg<any>): msg is Msg<AttendeeContent> {
58+
return (
59+
msg?.value?.content?.type === 'about' &&
60+
msg.value.content.about &&
61+
msg.value.content.attendee &&
62+
msg.value.content.attendee.link
63+
);
64+
}
65+
5666
export function isPrivate(msg: Msg<any> | UnboxedMsg): boolean {
5767
if ((msg as UnboxedMsg).meta?.private) return true;
5868
if ((msg as UnboxedMsg).value.private) return true;

0 commit comments

Comments
 (0)