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

Commit 072b810

Browse files
authored
Merge pull request #2668 from withspectrum/2.2.0
2.2.0
2 parents ed992e8 + 57b6cae commit 072b810

File tree

716 files changed

+18158
-5290
lines changed

Some content is hidden

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

716 files changed

+18158
-5290
lines changed

Diff for: .circleci/config.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ aliases:
4141
|
4242
node -e "const setup = require('./shared/testing/setup.js')().then(() => process.exit())"
4343
yarn run build:web
44-
yarn run build:iris
44+
yarn run build:api
4545

46-
- &start-iris
47-
name: Start Iris in the background
48-
command: TEST_DB=true yarn run dev:iris
46+
- &start-api
47+
name: Start the API in the background
48+
command: TEST_DB=true yarn run dev:api
4949
background: true
5050

5151
- &start-web
@@ -99,7 +99,7 @@ jobs:
9999
- run: *start-rethinkdb
100100
- run: sleep 10
101101
- run: *setup-and-build-web
102-
- run: *start-iris
102+
- run: *start-api
103103
- run: *start-web
104104
- run: sleep 60
105105
- run:

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ rethinkdb_data
1212
debug
1313
now-secrets.json
1414
build-iris
15+
build-api
1516
build-athena
1617
build-hermes
1718
build-chronos
@@ -28,6 +29,7 @@ queries-by-time.js
2829
test-extend.js
2930
stats.json
3031
iris/.env
32+
api/.env
3133
.expo
3234
mobile/.expo
3335
test-results.json

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+1-1

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rethinkdb_data
99
debug
1010
now-secrets.json
1111
build-iris
12+
build-api
1213
build-athena
1314
build-hermes
1415
build-chronos
@@ -25,6 +26,7 @@ queries-by-time.js
2526
test-extend.js
2627
stats.json
2728
iris/.env
29+
api/.env
2830
.expo
2931
mobile/.expo
3032
test-results.json

Diff for: README.md

+8-9

Diff for: admin/src/api/fragments/community/communityInfo.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const communityInfoFragment = gql`
1010
website
1111
profilePhoto
1212
coverPhoto
13+
hasChargeableSource
1314
communityPermissions {
1415
isMember
1516
isBlocked

Diff for: admin/src/api/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ export const clearApolloStore = () => {
6363
try {
6464
client.resetStore();
6565
} catch (e) {
66-
console.log('error clearing store');
66+
console.error('error clearing store');
6767
}
6868
};

Diff for: admin/src/views/communities/components/communitySettings/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class CommunitySettings extends Component {
9191
this.setState({
9292
isLoading: false,
9393
});
94-
console.log('error', err);
94+
console.error('error', err);
9595
});
9696
};
9797

Diff for: admin/src/views/users/components/userCommunitySettings/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class UserCommunitySettings extends Component {
9191
this.setState({
9292
isLoading: false,
9393
});
94-
console.log('error', err);
94+
console.error('error', err);
9595
});
9696
};
9797

File renamed without changes.

Diff for: iris/index.js renamed to api/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
console.log('Server starting...');
66
const compression = require('compression');
7-
const debug = require('debug')('iris');
7+
const debug = require('debug')('api');
88
debug('logging with debug enabled!');
99
import { createServer } from 'http';
1010
import express from 'express';
@@ -119,3 +119,5 @@ process.on('uncaughtException', async err => {
119119
process.exit(1);
120120
}
121121
});
122+
123+
//
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: iris/loaders/index.js renamed to api/loaders/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
__createDirectMessageSnippetLoader,
3737
} from './directMessageThread';
3838
import { __createReactionLoader } from './reaction';
39+
import { __createStripeCustomersLoader } from './stripe';
3940
import type { DataLoaderOptions } from './types';
4041

4142
// Create all the necessary loaders to be attached to the GraphQL context for each request
@@ -62,6 +63,7 @@ const createLoaders = (options?: DataLoaderOptions) => ({
6263
community: __createCommunityLoader(options),
6364
communityBySlug: __createCommunityBySlugLoader(options),
6465
communityRecurringPayments: __createCommunityRecurringPaymentsLoader(options),
66+
stripeCustomers: __createStripeCustomersLoader(options),
6567
communityChannelCount: __createCommunityChannelCountLoader(options),
6668
communityMemberCount: __createCommunityMemberCountLoader(options),
6769
communitySettings: __createCommunitySettingsLoader(options),
File renamed without changes.
File renamed without changes.

Diff for: api/loaders/stripe.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getStripeCustomersByCustomerIds } from '../models/stripeCustomers';
2+
import createLoader from './create-loader';
3+
4+
export const __createStripeCustomersLoader = createLoader(
5+
customers => getStripeCustomersByCustomerIds(customers),
6+
'group'
7+
);
File renamed without changes.
File renamed without changes.
File renamed without changes.
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
exports.up = function(r, conn) {
2+
const createCustomersTable = () =>
3+
r.tableCreate('stripeCustomers', { primaryKey: 'customerId' }).run(conn);
4+
const createInvoicesTable = () =>
5+
r.tableCreate('stripeInvoices', { primaryKey: 'invoiceId' }).run(conn);
6+
7+
return Promise.all([createCustomersTable(), createInvoicesTable()])
8+
.then(() =>
9+
Promise.all([
10+
r
11+
.table('stripeInvoices')
12+
.indexCreate('customerId')
13+
.run(conn),
14+
])
15+
)
16+
.catch(err => console.log(err));
17+
};
18+
19+
exports.down = function(r, conn) {
20+
return Promise.all([
21+
r.tableDrop('stripeCustomers').run(conn),
22+
r.tableDrop('stripeInvoices').run(conn),
23+
]);
24+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
exports.up = async (r, conn) => {
2+
const addFields = r
3+
.table('communities')
4+
.update({
5+
// a distinct email for each community where receipts and admin
6+
// messages will be sent, can be different from the owner's personal
7+
// email
8+
administratorEmail: null,
9+
// references the actual creator of the community, discrete from the 'owner'
10+
// role
11+
creatorId: null,
12+
// will be used to fetch records from the stripeCustomers and stripeInvoices
13+
// tables in order to populate the billing area and resolve query fields
14+
// for community features
15+
stripeCustomerId: null,
16+
// these are two feature flags that pluto will listen to changes for in
17+
// order to trigger billing events
18+
analyticsEnabled: false,
19+
prioritySupportEnabled: false,
20+
})
21+
.run(conn);
22+
23+
// gets all the owner records in a community, figures out which one is the oldest,
24+
// then uses that record to populate an administratorEmail and creatorId field
25+
// if they exist
26+
const oldestOwners = await r
27+
.table('usersCommunities')
28+
.filter({ isOwner: true })
29+
.group('communityId')
30+
.ungroup()
31+
.map(row => row('reduction'))
32+
.map(row => row.min('createdAt'))
33+
.eqJoin('userId', r.table('users'))
34+
.zip()
35+
.run(conn)
36+
.then(cursor => cursor.toArray());
37+
38+
const setAdminFields = oldestOwners.map(async owner => {
39+
if (!owner || !owner.userId || !owner.communityId) return;
40+
return await r
41+
.table('communities')
42+
.get(owner.communityId)
43+
.update({
44+
administratorEmail: owner.email,
45+
creatorId: owner.userId,
46+
})
47+
.run(conn);
48+
});
49+
50+
return Promise.all([addFields]).then(
51+
async () => await Promise.all(setAdminFields)
52+
);
53+
};
54+
55+
exports.down = function(r, conn) {
56+
return r
57+
.table('communities')
58+
.update({
59+
administratorEmail: r.literal(),
60+
creatorId: r.literal(),
61+
stripeCustomerId: r.literal(),
62+
analyticsEnabled: r.literal(),
63+
prioritySupportEnabled: r.literal(),
64+
})
65+
.run(conn);
66+
};

Diff for: iris/migrations/config.js renamed to api/migrations/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const DEFAULT_CONFIG = {
66
db: process.env.NODE_ENV === 'test' ? 'testing' : 'spectrum',
77
host: 'localhost',
88
port: 28015,
9-
migrationsDirectory: 'iris/migrations',
9+
migrationsDirectory: 'api/migrations',
1010
};
1111

1212
const RUN_IN_PROD = !!process.env.AWS_RETHINKDB_PASSWORD;

Diff for: api/migrations/seed/default/channels.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// @flow
2+
const constants = require('./constants');
3+
const {
4+
DATE,
5+
SPECTRUM_COMMUNITY_ID,
6+
PAYMENTS_COMMUNITY_ID,
7+
SPECTRUM_GENERAL_CHANNEL_ID,
8+
SPECTRUM_PRIVATE_CHANNEL_ID,
9+
PAYMENTS_GENERAL_CHANNEL_ID,
10+
PAYMENTS_PRIVATE_CHANNEL_ID,
11+
} = constants;
12+
13+
module.exports = [
14+
{
15+
id: SPECTRUM_GENERAL_CHANNEL_ID,
16+
communityId: SPECTRUM_COMMUNITY_ID,
17+
createdAt: new Date(DATE),
18+
name: 'General',
19+
description: 'General chatter',
20+
slug: 'general',
21+
isPrivate: false,
22+
isDefault: true,
23+
},
24+
25+
{
26+
id: SPECTRUM_PRIVATE_CHANNEL_ID,
27+
communityId: SPECTRUM_COMMUNITY_ID,
28+
createdAt: new Date(DATE),
29+
name: 'Private',
30+
description: 'Private chatter',
31+
slug: 'private',
32+
isPrivate: true,
33+
isDefault: false,
34+
},
35+
36+
{
37+
id: PAYMENTS_GENERAL_CHANNEL_ID,
38+
communityId: PAYMENTS_COMMUNITY_ID,
39+
createdAt: new Date(DATE),
40+
name: 'General',
41+
description: 'General chatter',
42+
slug: 'general',
43+
isPrivate: false,
44+
isDefault: true,
45+
},
46+
47+
{
48+
id: PAYMENTS_PRIVATE_CHANNEL_ID,
49+
communityId: PAYMENTS_COMMUNITY_ID,
50+
createdAt: new Date(DATE),
51+
name: 'Private',
52+
description: 'Private chatter',
53+
slug: 'private',
54+
isPrivate: true,
55+
isDefault: false,
56+
},
57+
];

Diff for: api/migrations/seed/default/communities.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// @flow
2+
const constants = require('./constants');
3+
const { DATE, SPECTRUM_COMMUNITY_ID, PAYMENTS_COMMUNITY_ID } = constants;
4+
5+
module.exports = [
6+
{
7+
id: SPECTRUM_COMMUNITY_ID,
8+
createdAt: new Date(DATE),
9+
name: 'Spectrum',
10+
description: 'The future of communities',
11+
website: 'https://spectrum.chat',
12+
profilePhoto:
13+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Profile.png.0.6225566835336693',
14+
coverPhoto:
15+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Header.png.0.3303118636071434',
16+
slug: 'spectrum',
17+
},
18+
{
19+
id: PAYMENTS_COMMUNITY_ID,
20+
createdAt: new Date(DATE),
21+
name: 'Payments',
22+
description: 'Where payments are tested',
23+
website: 'https://spectrum.chat',
24+
profilePhoto:
25+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Profile.png.0.6225566835336693',
26+
coverPhoto:
27+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Header.png.0.3303118636071434',
28+
slug: 'payments',
29+
},
30+
];

0 commit comments

Comments
 (0)