-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Github
connection, UX improvements
- Loading branch information
Showing
18 changed files
with
1,197 additions
and
1,518 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// ******************** // | ||
// The removeConnectionGithub account event file. | ||
// ******************** // | ||
|
||
import { | ||
RemoveConnectionGithubResult, | ||
RemoveConnectionGithubServerParams, | ||
} from 'interfaces/account/removeConnectionGithub'; | ||
import { EventTemplate, FronvoError } from 'interfaces/all'; | ||
import { prismaClient } from 'variables/global'; | ||
|
||
async function removeConnectionGithub({ | ||
io, | ||
socket, | ||
account, | ||
}: RemoveConnectionGithubServerParams): Promise< | ||
RemoveConnectionGithubResult | FronvoError | ||
> { | ||
if (!account.hasSpotify) { | ||
return; | ||
} | ||
|
||
try { | ||
await prismaClient.account.update({ | ||
where: { | ||
profileId: account.profileId, | ||
}, | ||
|
||
data: { | ||
hasGithub: false, | ||
githubName: '', | ||
githubURL: '', | ||
}, | ||
}); | ||
|
||
io.to(account.profileId) | ||
.to(socket.id) | ||
.emit('connectionsUpdated', { | ||
profileId: account.profileId, | ||
|
||
github: { | ||
hasGithub: false, | ||
githubName: '', | ||
githubURL: '', | ||
}, | ||
}); | ||
} catch (e) {} | ||
|
||
return {}; | ||
} | ||
|
||
const removeConnectionGithubTemplate: EventTemplate = { | ||
func: removeConnectionGithub, | ||
template: [], | ||
}; | ||
|
||
export default removeConnectionGithubTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// ******************** // | ||
// The updateConnectionGithub account event file. | ||
// ******************** // | ||
|
||
import { StringSchema } from '@ezier/validate'; | ||
import { | ||
UpdateConnectionGithubResult, | ||
UpdateConnectionGithubServerParams, | ||
} from 'interfaces/account/updateConnectionGithub'; | ||
import { EventTemplate, FronvoError } from 'interfaces/all'; | ||
import { generateError, getLoggedInSockets } from 'utilities/global'; | ||
import { prismaClient } from 'variables/global'; | ||
import { getEnv } from 'variables/varUtils'; | ||
|
||
async function updateConnectionGithub({ | ||
io, | ||
socket, | ||
account, | ||
name, | ||
url, | ||
secret, | ||
}: UpdateConnectionGithubServerParams): Promise< | ||
UpdateConnectionGithubResult | FronvoError | ||
> { | ||
if (secret != getEnv('GENERAL_SECRET')) { | ||
return generateError('UNKNOWN'); | ||
} | ||
|
||
try { | ||
await prismaClient.account.update({ | ||
where: { | ||
profileId: account.profileId, | ||
}, | ||
|
||
data: { | ||
hasGithub: true, | ||
githubName: name, | ||
githubURL: url, | ||
}, | ||
}); | ||
|
||
io.to(account.profileId) | ||
.to(socket.id) | ||
.emit('connectionsUpdated', { | ||
profileId: account.profileId, | ||
|
||
github: { | ||
hasGithub: true, | ||
githubName: name, | ||
githubURL: url, | ||
}, | ||
}); | ||
|
||
// To all sockets in this account | ||
const targetSockets = getLoggedInSockets(); | ||
|
||
for (const socketIndex in targetSockets) { | ||
const socketObj = targetSockets[socketIndex]; | ||
|
||
if ( | ||
socketObj.accountId == account.profileId && | ||
socketObj.socket.id != socket.id | ||
) { | ||
io.to(socketObj.socket.id).emit('connectionsUpdated', { | ||
profileId: account.profileId, | ||
|
||
github: { | ||
hasGithub: true, | ||
githubName: name, | ||
githubURL: url, | ||
}, | ||
}); | ||
} | ||
} | ||
} catch (e) {} | ||
|
||
return {}; | ||
} | ||
|
||
const updateConnectionGithubTemplate: EventTemplate = { | ||
func: updateConnectionGithub, | ||
template: ['name', 'url', 'secret'], | ||
schema: new StringSchema({ | ||
name: {}, | ||
|
||
url: {}, | ||
|
||
secret: { | ||
minLength: 36, | ||
}, | ||
}), | ||
}; | ||
|
||
export default updateConnectionGithubTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// ******************** // | ||
// Interfaces for the removeConnectionGithub event file. | ||
// ******************** // | ||
|
||
import { FronvoError, EventArguments } from 'interfaces/all'; | ||
|
||
export interface RemoveConnectionGithubParams {} | ||
|
||
export interface RemoveConnectionGithubServerParams | ||
extends EventArguments, | ||
RemoveConnectionGithubParams {} | ||
|
||
export interface RemoveConnectionGithubResult {} | ||
|
||
export interface RemoveConnectionGithubTestResult | ||
extends FronvoError, | ||
RemoveConnectionGithubResult {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.