Add alias support for experimental discord (#1848)

This updates the alias "plugin" to support the experimental Discord
plugin that we recently merged into master. Without this, we can't
resolve Discord aliases.

Test plan: Validated on SourceCred's own cred instance. No unit tests
added since both modules in question (experimental discord and alias)
are going to be replaced or re-written, and the experimental-discord
plugin has no testing at all.
This commit is contained in:
Dandelion Mané 2020-06-08 00:19:54 -07:00 committed by GitHub
parent a38860a3d2
commit 87dd43d057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import {loginAddress as githubAddress} from "../github/nodes";
import {userNodeType as githubUserType} from "../github/declaration";
import {userAddress as discourseAddress} from "../discourse/address";
import {userNodeType as discourseUserType} from "../discourse/declaration";
import {userAddress as discordAddress} from "../experimental-discord/createGraph";
import {memberNodeType as discordUserType} from "../experimental-discord/declaration";
import {identityType} from "./declaration";
import {
identityAddress,
@ -40,6 +42,9 @@ export function resolveAlias(
}
const [_, prefix, name] = match;
switch (prefix) {
case "discord": {
return discordAddress(name);
}
case "github": {
const match = name.match(_VALID_GITHUB_NAME);
if (!match) {
@ -85,6 +90,7 @@ export function toAlias(n: NodeAddressT): Alias | null {
["github", githubUserType.prefix],
["discourse", discourseUserType.prefix],
["sourcecred", identityType.prefix],
["discord", discordUserType.prefix],
]);
for (const [prefix, nodePrefix] of prefixes.entries()) {