Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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