Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit bc2bc87

Browse files
committed
Merge branch 'alpha' of github.com:withspectrum/spectrum into message-syntax-highlighting
2 parents e2d8786 + de64b3b commit bc2bc87

File tree

71 files changed

+1811
-838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1811
-838
lines changed

api/migrations/seed/default/channels.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ const {
66
PAYMENTS_COMMUNITY_ID,
77
DELETED_COMMUNITY_ID,
88
PRIVATE_COMMUNITY_ID,
9+
SINGLE_CHANNEL_COMMUNITY_ID,
910
SPECTRUM_GENERAL_CHANNEL_ID,
1011
SPECTRUM_PRIVATE_CHANNEL_ID,
1112
PAYMENTS_GENERAL_CHANNEL_ID,
1213
PAYMENTS_PRIVATE_CHANNEL_ID,
14+
PAYMENTS_FEATURES_CHANNEL_ID,
1315
SPECTRUM_ARCHIVED_CHANNEL_ID,
1416
SPECTRUM_DELETED_CHANNEL_ID,
1517
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
1618
MODERATOR_CREATED_CHANNEL_ID,
1719
PRIVATE_GENERAL_CHANNEL_ID,
20+
SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
1821
} = constants;
1922

2023
module.exports = [
@@ -66,6 +69,18 @@ module.exports = [
6669
memberCount: 5,
6770
},
6871

72+
{
73+
id: PAYMENTS_FEATURES_CHANNEL_ID,
74+
communityId: PAYMENTS_COMMUNITY_ID,
75+
createdAt: new Date(DATE),
76+
name: 'Payments Features',
77+
description: 'Payments Features',
78+
slug: 'features',
79+
isPrivate: false,
80+
isDefault: false,
81+
memberCount: 5,
82+
},
83+
6984
{
7085
id: SPECTRUM_ARCHIVED_CHANNEL_ID,
7186
communityId: SPECTRUM_COMMUNITY_ID,
@@ -128,4 +143,16 @@ module.exports = [
128143
isDefault: false,
129144
memberCount: 1,
130145
},
146+
147+
{
148+
id: SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
149+
communityId: SINGLE_CHANNEL_COMMUNITY_ID,
150+
createdAt: new Date(DATE),
151+
name: 'General',
152+
description: 'General',
153+
slug: 'general',
154+
isPrivate: false,
155+
isDefault: false,
156+
memberCount: 1,
157+
},
131158
];

api/migrations/seed/default/communities.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
PAYMENTS_COMMUNITY_ID,
77
DELETED_COMMUNITY_ID,
88
PRIVATE_COMMUNITY_ID,
9+
SINGLE_CHANNEL_COMMUNITY_ID,
910
} = constants;
1011

1112
module.exports = [
@@ -66,4 +67,18 @@ module.exports = [
6667
slug: 'private',
6768
memberCount: 1,
6869
},
70+
{
71+
id: SINGLE_CHANNEL_COMMUNITY_ID,
72+
createdAt: new Date(DATE),
73+
isPrivate: false,
74+
name: 'Single channel community',
75+
description: 'Single channel community',
76+
website: 'https://spectrum.chat',
77+
profilePhoto:
78+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Profile.png.0.6225566835336693',
79+
coverPhoto:
80+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Header.png.0.3303118636071434',
81+
slug: 'single',
82+
memberCount: 1,
83+
},
6984
];

api/migrations/seed/default/constants.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,29 @@ const PENDING_USER_ID = '7';
1717
const CHANNEL_MODERATOR_USER_ID = '8';
1818
// this user is moderator in all communities
1919
const COMMUNITY_MODERATOR_USER_ID = '9';
20+
// this user is only a member of one community, and that community only has
21+
// one channel - use for testing the composer community+channel selection
22+
const SINGLE_CHANNEL_COMMUNITY_USER_ID = '10';
2023

2124
// communities
2225
const SPECTRUM_COMMUNITY_ID = '1';
2326
const PAYMENTS_COMMUNITY_ID = '2';
2427
const DELETED_COMMUNITY_ID = '3';
2528
const PRIVATE_COMMUNITY_ID = '4';
29+
const SINGLE_CHANNEL_COMMUNITY_ID = '5';
2630

2731
// channels
2832
const SPECTRUM_GENERAL_CHANNEL_ID = '1';
2933
const SPECTRUM_PRIVATE_CHANNEL_ID = '2';
3034
const PAYMENTS_GENERAL_CHANNEL_ID = '3';
3135
const PAYMENTS_PRIVATE_CHANNEL_ID = '4';
36+
const PAYMENTS_FEATURES_CHANNEL_ID = '10';
3237
const SPECTRUM_ARCHIVED_CHANNEL_ID = '5';
3338
const SPECTRUM_DELETED_CHANNEL_ID = '6';
3439
const DELETED_COMMUNITY_DELETED_CHANNEL_ID = '7';
3540
const MODERATOR_CREATED_CHANNEL_ID = '8';
3641
const PRIVATE_GENERAL_CHANNEL_ID = '9';
42+
const SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID = '11';
3743

3844
module.exports = {
3945
DATE,
@@ -46,17 +52,21 @@ module.exports = {
4652
PENDING_USER_ID,
4753
CHANNEL_MODERATOR_USER_ID,
4854
COMMUNITY_MODERATOR_USER_ID,
55+
SINGLE_CHANNEL_COMMUNITY_USER_ID,
4956
SPECTRUM_COMMUNITY_ID,
5057
PAYMENTS_COMMUNITY_ID,
5158
DELETED_COMMUNITY_ID,
5259
PRIVATE_COMMUNITY_ID,
60+
SINGLE_CHANNEL_COMMUNITY_ID,
5361
SPECTRUM_GENERAL_CHANNEL_ID,
5462
SPECTRUM_PRIVATE_CHANNEL_ID,
5563
PAYMENTS_GENERAL_CHANNEL_ID,
5664
PAYMENTS_PRIVATE_CHANNEL_ID,
65+
PAYMENTS_FEATURES_CHANNEL_ID,
5766
SPECTRUM_ARCHIVED_CHANNEL_ID,
5867
SPECTRUM_DELETED_CHANNEL_ID,
5968
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
6069
MODERATOR_CREATED_CHANNEL_ID,
6170
PRIVATE_GENERAL_CHANNEL_ID,
71+
SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
6272
};

api/migrations/seed/default/messages.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,21 @@ module.exports = [
186186
senderId: BRYN_ID,
187187
timestamp: new Date(DATE + 300000),
188188
},
189+
{
190+
id: '14',
191+
threadId: 'thread-6',
192+
threadType: 'story',
193+
content: {
194+
body: JSON.stringify(
195+
toJSON(
196+
fromPlainText(
197+
'http://localhost:3000/spectrum/general/yet-another-thread~thread-9'
198+
)
199+
)
200+
),
201+
},
202+
messageType: 'draftjs',
203+
senderId: BRIAN_ID,
204+
timestamp: new Date(DATE + 300000),
205+
},
189206
];

api/migrations/seed/default/users.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
PREVIOUS_MEMBER_USER_ID,
1010
CHANNEL_MODERATOR_USER_ID,
1111
COMMUNITY_MODERATOR_USER_ID,
12+
SINGLE_CHANNEL_COMMUNITY_USER_ID,
1213
DATE,
1314
} = constants;
1415

@@ -128,4 +129,18 @@ module.exports = [
128129
createdAt: new Date(DATE),
129130
lastSeen: new Date(DATE),
130131
},
132+
{
133+
id: SINGLE_CHANNEL_COMMUNITY_USER_ID,
134+
name: 'Single community person',
135+
description: 'Im a member of one community',
136+
website: '',
137+
username: 'single-community-user',
138+
profilePhoto:
139+
'https://pbs.twimg.com/profile_images/848823167699230721/-9CbPtto_bigger.jpg',
140+
coverPhoto:
141+
'https://pbs.twimg.com/profile_banners/17106008/1491444958/1500x500',
142+
143+
createdAt: new Date(DATE),
144+
lastSeen: new Date(DATE),
145+
},
131146
];

api/migrations/seed/default/usersChannels.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ const {
99
PREVIOUS_MEMBER_USER_ID,
1010
CHANNEL_MODERATOR_USER_ID,
1111
COMMUNITY_MODERATOR_USER_ID,
12+
SINGLE_CHANNEL_COMMUNITY_USER_ID,
1213
SPECTRUM_GENERAL_CHANNEL_ID,
1314
PRIVATE_GENERAL_CHANNEL_ID,
1415
SPECTRUM_ARCHIVED_CHANNEL_ID,
1516
SPECTRUM_PRIVATE_CHANNEL_ID,
1617
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
1718
PAYMENTS_GENERAL_CHANNEL_ID,
1819
PAYMENTS_PRIVATE_CHANNEL_ID,
20+
PAYMENTS_FEATURES_CHANNEL_ID,
1921
MODERATOR_CREATED_CHANNEL_ID,
22+
SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
2023
} = constants;
2124

2225
module.exports = [
@@ -142,6 +145,18 @@ module.exports = [
142145
isPending: false,
143146
receiveNotifications: true,
144147
},
148+
{
149+
id: '32',
150+
createdAt: new Date(DATE),
151+
userId: BRIAN_ID,
152+
channelId: PAYMENTS_FEATURES_CHANNEL_ID,
153+
isOwner: true,
154+
isModerator: false,
155+
isMember: true,
156+
isBlocked: false,
157+
isPending: false,
158+
receiveNotifications: true,
159+
},
145160
{
146161
id: '11',
147162
createdAt: new Date(DATE),
@@ -396,4 +411,28 @@ module.exports = [
396411
isPending: false,
397412
receiveNotifications: false,
398413
},
414+
{
415+
id: '33',
416+
createdAt: new Date(DATE),
417+
userId: BRIAN_ID,
418+
channelId: SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
419+
isOwner: false,
420+
isModerator: false,
421+
isMember: true,
422+
isBlocked: false,
423+
isPending: false,
424+
receiveNotifications: false,
425+
},
426+
{
427+
id: '34',
428+
createdAt: new Date(DATE),
429+
userId: SINGLE_CHANNEL_COMMUNITY_USER_ID,
430+
channelId: SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
431+
isOwner: false,
432+
isModerator: false,
433+
isMember: true,
434+
isBlocked: false,
435+
isPending: false,
436+
receiveNotifications: false,
437+
},
399438
];

api/migrations/seed/default/usersCommunities.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ const {
99
BLOCKED_USER_ID,
1010
CHANNEL_MODERATOR_USER_ID,
1111
COMMUNITY_MODERATOR_USER_ID,
12+
SINGLE_CHANNEL_COMMUNITY_USER_ID,
1213
SPECTRUM_COMMUNITY_ID,
1314
PAYMENTS_COMMUNITY_ID,
1415
PRIVATE_COMMUNITY_ID,
16+
SINGLE_CHANNEL_COMMUNITY_ID,
1517
} = constants;
1618

1719
module.exports = [
@@ -39,7 +41,7 @@ module.exports = [
3941
isBlocked: false,
4042
isPending: false,
4143
receiveNotifications: true,
42-
reputation: 100,
44+
reputation: 101,
4345
},
4446
{
4547
id: '3',
@@ -199,4 +201,32 @@ module.exports = [
199201
receiveNotifications: true,
200202
reputation: 100,
201203
},
204+
205+
{
206+
id: '16',
207+
createdAt: new Date(DATE),
208+
userId: BRIAN_ID,
209+
communityId: SINGLE_CHANNEL_COMMUNITY_ID,
210+
isOwner: false,
211+
isModerator: false,
212+
isMember: true,
213+
isBlocked: false,
214+
isPending: false,
215+
receiveNotifications: true,
216+
reputation: 0,
217+
},
218+
219+
{
220+
id: '17',
221+
createdAt: new Date(DATE),
222+
userId: SINGLE_CHANNEL_COMMUNITY_USER_ID,
223+
communityId: SINGLE_CHANNEL_COMMUNITY_ID,
224+
isOwner: false,
225+
isModerator: false,
226+
isMember: true,
227+
isBlocked: false,
228+
isPending: false,
229+
receiveNotifications: true,
230+
reputation: 0,
231+
},
202232
];

api/migrations/seed/default/usersSettings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module.exports = () => {
44
let settings = [];
5-
for (let step = 0; step < 10; step++) {
5+
for (let step = 0; step < 11; step++) {
66
settings.push({
77
userId: step.toString(),
88
notifications: {

api/models/test/__snapshots__/channel.test.js.snap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ Array [
8585
"receiveNotifications": true,
8686
"slug": "private",
8787
},
88+
Object {
89+
"communityId": "5",
90+
"createdAt": 2016-12-31T23:00:00.000Z,
91+
"description": "General",
92+
"id": "11",
93+
"isBlocked": false,
94+
"isDefault": false,
95+
"isMember": true,
96+
"isModerator": false,
97+
"isOwner": false,
98+
"isPending": false,
99+
"isPrivate": false,
100+
"memberCount": 1,
101+
"name": "General",
102+
"receiveNotifications": false,
103+
"slug": "general",
104+
},
88105
Object {
89106
"communityId": "1",
90107
"createdAt": 2016-12-31T23:00:00.000Z,
@@ -119,6 +136,23 @@ Array [
119136
"receiveNotifications": true,
120137
"slug": "general",
121138
},
139+
Object {
140+
"communityId": "2",
141+
"createdAt": 2016-12-31T23:00:00.000Z,
142+
"description": "Payments Features",
143+
"id": "10",
144+
"isBlocked": false,
145+
"isDefault": false,
146+
"isMember": true,
147+
"isModerator": false,
148+
"isOwner": true,
149+
"isPending": false,
150+
"isPrivate": false,
151+
"memberCount": 5,
152+
"name": "Payments Features",
153+
"receiveNotifications": true,
154+
"slug": "features",
155+
},
122156
Object {
123157
"communityId": "2",
124158
"createdAt": 2016-12-31T23:00:00.000Z,

api/queries/community/channelConnection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { canViewCommunity } from '../../utils/permissions';
77
export default async ({ id }: DBCommunity, _: any, ctx: GraphQLContext) => {
88
const { user, loaders } = ctx;
99

10-
if (!await canViewCommunity(user, id, loaders)) {
10+
if (!(await canViewCommunity(user, id, loaders))) {
1111
return {
1212
pageInfo: {
1313
hasNextPage: false,

0 commit comments

Comments
 (0)