Skip to content

Commit

Permalink
bug fixes, add planet info card to sidebar, make / home and remove la…
Browse files Browse the repository at this point in the history
…nding page, improve 404 page, remove electron build from workflow, add seed script, v0.0.61
  • Loading branch information
yayvery committed May 18, 2021
1 parent 1aa96e2 commit 1405f68
Show file tree
Hide file tree
Showing 43 changed files with 618 additions and 619 deletions.
97 changes: 1 addition & 96 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,88 +72,8 @@ jobs:
name: dist-web
path: web/dist/

web-electron:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 15
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn
- run: yarn run build:web
env:
VITE_API_DOMAIN: ${{ secrets.API_DOMAIN }}
ELECTRON: true
- uses: actions/upload-artifact@v2
with:
name: dist-electron
path: electron/dist/

electron:
needs: [web-electron]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: 15
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn
- uses: actions/download-artifact@v2
with:
name: dist-electron
path: electron/dist
- name: Prepare for app notarization
if: startsWith(matrix.os, 'macos')
# Import Apple API key for app notarization on macOS
run: |
mkdir -p ~/private_keys/
echo '${{ secrets.api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
- name: Build/release Electron app
uses: CryogenicPlanet/action-electron-builder@v2 # Using CryogenicPlanet until the main action adds skip_install
with:
skip_build: true
skip_install: true
package_root: electron
github_token: ${{ secrets.github_token }}
max_attempts: 3
# If the commit is tagged with a version (e.g. "v1.0.0"), release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
mac_certs: ${{ secrets.mac_certs }}
mac_certs_password: ${{ secrets.mac_certs_password }}
env:
# macOS notarization API key
API_KEY_ID: ${{ secrets.api_key_id }}
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}

deploy:
needs: [web, electron, server]
needs: [web, server]
runs-on: ubuntu-latest
steps:
- name: Prepare
Expand Down Expand Up @@ -198,18 +118,3 @@ jobs:
clean: true
clean-exclude: |
404.html
release:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- name: Get version from ref
id: get-version
run: |
ver=$(echo ${GITHUB_REF/refs\/tags\//} | cut -c 2-)
echo ::set-output name=VERSION::$ver
- name: Publish release on GitHub
uses: test-room-7/action-publish-release-drafts@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tag-name: ${{ steps.get-version.outputs.VERSION }}
6 changes: 3 additions & 3 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron",
"description": "All-in-one chat and forums for communities.",
"version": "0.0.60",
"version": "0.0.61",
"private": true,
"repository": "github:joincomet/comet",
"homepage": "https://joincomet.app",
Expand All @@ -23,15 +23,15 @@
"cross-env": "^7.0.3",
"discord-rpc": "^3.2.0",
"electron-builder-notarize": "^1.2.0",
"electron-context-menu": "^3.0.0",
"electron-context-menu": "^3.1.0",
"electron-is-dev": "^2.0.0",
"electron-log": "^4.3.5",
"electron-store": "^8.0.0",
"electron-updater": "^4.3.9",
"typescript": "^4.2.4"
},
"devDependencies": {
"electron": "12.0.7",
"electron": "12.0.8",
"electron-builder": "^22.11.4"
},
"build": {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "comet",
"version": "0.0.60",
"version": "0.0.61",
"private": true,
"license": "MPL-2.0",
"author": {
Expand Down Expand Up @@ -33,8 +33,8 @@
"@graphql-codegen/typescript-operations": "^1.17.16",
"@graphql-codegen/typescript-react-apollo": "^2.2.4",
"@types/node": "^15.3.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"concurrently": "^6.1.0",
"cross-env": "^7.0.3",
"eslint": "^7.26.0",
Expand Down
16 changes: 7 additions & 9 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ input ChangeOnlineStatusInput {
onlineStatus: OnlineStatus!
}

input ChangePasswordInput {
currentPassword: String!
password: String!
}

input ChangeUserAvatarInput {
avatarFile: Upload
}
Expand Down Expand Up @@ -175,6 +180,7 @@ input CreateServerInput {
avatarFile: Upload
bannerFile: Upload
category: ServerCategory = Other
description: String
displayName: String!
name: String!
}
Expand Down Expand Up @@ -419,6 +425,7 @@ type Mutation {
banUserFromServer(input: BanUserFromServerInput!): Boolean!
blockUser(input: BlockUserInput!): User!
changeOnlineStatus(input: ChangeOnlineStatusInput!): User!
changePassword(input: ChangePasswordInput!): User!
changeUserAvatar(input: ChangeUserAvatarInput!): User!
closeDm(input: CloseDmInput!): User!
createAccount(input: CreateAccountInput!): LoginResponse!
Expand Down Expand Up @@ -474,7 +481,6 @@ type Mutation {
unpinPost(input: UnpinPostInput!): Post!
unvoteComment(input: UnvoteCommentInput!): Comment!
unvotePost(input: UnvotePostInput!): Post!
updateAccount(input: UpdateAccountInput!): User!
updateChannel(input: UpdateChannelInput!): Channel!
updateComment(input: UpdateCommentInput!): Comment!
updateFolder(input: UpdateFolderInput!): Folder!
Expand Down Expand Up @@ -787,13 +793,6 @@ input UnvotePostInput {
postId: ID!
}

input UpdateAccountInput {
currentPassword: String!
email: EmailAddress
password: String
username: String
}

input UpdateChannelInput {
channelId: ID!
name: String
Expand Down Expand Up @@ -863,7 +862,6 @@ type User implements BaseEntity {
isAdmin: Boolean!
isCurrentUser: Boolean!
isOnline: Boolean!
isPremium: Boolean!
lastLoginAt: DateTime
lastMessageAt: DateTime
onlineStatus: OnlineStatus!
Expand Down
14 changes: 7 additions & 7 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "server",
"version": "0.0.60",
"version": "0.0.61",
"private": true,
"engines": {
"node": "15.x.x"
Expand All @@ -12,15 +12,15 @@
"build": "tsc"
},
"dependencies": {
"@mikro-orm/core": "^4.5.4",
"@mikro-orm/migrations": "^4.5.4",
"@mikro-orm/postgresql": "^4.5.4",
"@mikro-orm/core": "^4.5.5",
"@mikro-orm/migrations": "^4.5.5",
"@mikro-orm/postgresql": "^4.5.5",
"@mikro-orm/sql-highlighter": "^1.0.1",
"@n1ru4l/graphql-live-query": "^0.7.1",
"@n1ru4l/in-memory-live-query-store": "^0.6.4",
"apollo-server-express": "^2.24.0",
"argon2": "^0.27.2",
"aws-sdk": "^2.907.0",
"aws-sdk": "^2.908.0",
"class-validator": "^0.13.1",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -59,7 +59,7 @@
"sharp": "^0.28.2",
"type-graphql": "^1.1.1",
"typescript": "^4.2.4",
"user-agents": "^1.0.653",
"user-agents": "^1.0.655",
"validator": "^13.6.0",
"ws": "^7.4.5",
"xss": "^1.0.9"
Expand All @@ -70,7 +70,7 @@
"@types/express": "^4.17.11",
"@types/faker": "^5.5.5",
"@types/graphql-upload": "^8.0.4",
"@types/ioredis": "^4.26.3",
"@types/ioredis": "^4.26.4",
"@types/jsonwebtoken": "^8.5.1",
"@types/mime": "^2.0.3",
"@types/sanitize-html": "^2.3.1",
Expand Down
15 changes: 11 additions & 4 deletions server/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,29 @@ import { useServer } from 'graphql-ws/lib/use/ws'
import { specifiedRules } from 'graphql'
import { NoLiveMixedWithDeferStreamRule } from '@n1ru4l/graphql-live-query'
import { graphqlUploadExpress } from 'graphql-upload'
import { getUserId, RedisLiveQueryStore } from '@/util'
import { getUserId, MAX_FILE_SIZE, RedisLiveQueryStore } from '@/util'
import { Context } from '@/types'
import { createLoaders } from '@/util/loaders/createLoaders'
import cors from 'cors'
import { InMemoryLiveQueryStore } from '@n1ru4l/in-memory-live-query-store'
import { Disposable } from 'graphql-ws'
import { seed } from '@/seed/seed'

const validationRules = [...specifiedRules, NoLiveMixedWithDeferStreamRule]

const RESET = true // set TRUE to WIPE AND RESET DATABASE in dev

export async function bootstrap() {
console.log(`Initializing database connection...`)
const orm = await MikroORM.init(mikroOrmConf)

if (process.env.NODE_ENV !== 'production') {
console.log(`Setting up the database...`)
const generator = orm.getSchemaGenerator()
// await generator.dropSchema(false)
// await generator.createSchema(false)
if (RESET) {
await generator.dropSchema(false)
await generator.createSchema(false)
}
await generator.updateSchema(false)
}

Expand All @@ -41,7 +46,7 @@ export async function bootstrap() {
app.use(cors({ origin: true }))
app.use(
graphqlUploadExpress({
maxFileSize: 32 * 1024 * 1024, // 32MB limit
maxFileSize: MAX_FILE_SIZE,
maxFiles: 20
})
)
Expand Down Expand Up @@ -97,4 +102,6 @@ export async function bootstrap() {
server.close()
orm.close()
})

await seed(orm.em.fork())
}
6 changes: 3 additions & 3 deletions server/src/entity/server/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export class Server extends BaseEntity {
@Property()
isFeatured: boolean = false

@Field()
isJoined: boolean

@Property({ nullable: true, columnType: 'text' })
featuredPosition?: string

@Field()
isJoined: boolean
}
10 changes: 0 additions & 10 deletions server/src/entity/user/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ export class User extends BaseEntity {
@Property({ nullable: true, columnType: 'text' })
banReason?: string

@Property({ nullable: true })
purchasedPremiumAt?: Date

@OneToMany(() => UserFolder, 'user', {
orderBy: { position: QueryOrder.ASC }
})
Expand Down Expand Up @@ -132,13 +129,6 @@ export class User extends BaseEntity {
return new Date().getTime() - this.lastLoginAt.getTime() < timeout
}

@Field()
get isPremium(): boolean {
if (!this.purchasedPremiumAt) return false
const millis = 30 * 24 * 60 * 60 * 1000 // 30 days
return new Date().getTime() - this.purchasedPremiumAt.getTime() < millis
}

async isBannedFromServer(
em: EntityManager,
serverId: string
Expand Down
7 changes: 4 additions & 3 deletions server/src/resolver/server/mutations/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class CreateServerInput {
@Matches(serverRegex)
displayName: string

@Field({ nullable: true })
@Length(0, 500)
description?: string

@Field(() => ServerCategory, { defaultValue: ServerCategory.Other })
category: ServerCategory = ServerCategory.Other

Expand All @@ -43,9 +47,6 @@ export async function createServer(
{ em, userId, liveQueryStore }: Context,
{ name, displayName, category, avatarFile, bannerFile }: CreateServerInput
): Promise<Server> {
if ((await em.count(ServerUser, { user: userId })) >= 100)
throw new Error('error.server.joinLimit')

let avatarUrl = null
if (avatarFile) {
avatarUrl = await uploadImageFileSingle(
Expand Down
Loading

0 comments on commit 1405f68

Please sign in to comment.