Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable alias voting and propose globally #347

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
19 changes: 8 additions & 11 deletions src/ingestor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,29 @@ export default async function ingestor(req) {
if (!Object.keys(hashTypes).includes(hash)) return Promise.reject('wrong types');
type = hashTypes[hash];

let aliased = false;
if (!['settings', 'alias', 'profile'].includes(type)) {
if (!message.space) return Promise.reject('unknown space');

const space = await getSpace(message.space, false, message.network);
if (!space) return Promise.reject('unknown space');
network = space.network;
if (space.voting?.aliased) aliased = true;
}

// Check if signing address is an alias
const aliasTypes = ['follow', 'unfollow', 'subscribe', 'unsubscribe', 'profile'];
const aliasOptionTypes = [
const aliasTypes = [
'follow',
'unfollow',
'subscribe',
'unsubscribe',
'profile',
'vote',
'vote-array',
'vote-string',
'proposal',
'delete-proposal',
'statement'
'update-proposal'
];
if (body.address !== message.from) {
if (!aliasTypes.includes(type) && !aliasOptionTypes.includes(type))
return Promise.reject('wrong from');

if (aliasOptionTypes.includes(type) && !aliased) return Promise.reject('alias not enabled');

if (!aliasTypes.includes(type)) return Promise.reject('wrong from');
if (!(await isValidAlias(message.from, body.address))) return Promise.reject('wrong alias');
}

Expand Down
Loading