<commit_before>import * as express from 'express';
import context from '../../remote/activitypub/renderer/context';
import render from '../../remote/activitypub/renderer/key';
import User from '../../models/user';

const app = express.Router();

app.get('/users/:user/publickey', async (req, res) => {
	const userId = req.params.user;

	const user = await User.findOne({ _id: userId });

	const rendered = render(user);
	rendered['@context'] = context;

	res.json(rendered);
});

export default app;<commit_msg>Check whether is local user<commit_after>import * as express from 'express';
import context from '../../remote/activitypub/renderer/context';
import render from '../../remote/activitypub/renderer/key';
import User, { isLocalUser } from '../../models/user';

const app = express.Router();

app.get('/users/:user/publickey', async (req, res) => {
	const userId = req.params.user;

	const user = await User.findOne({ _id: userId });

	if (isLocalUser(user)) {
		const rendered = render(user);
		rendered['@context'] = context;

		res.json(rendered);
	} else {
		res.sendStatus(400);
	}
});

export default app;
{'fraction_non_alphanumeric': 0.1779964221824687, 'fraction_numerical': 0.0026833631484794273, 'mean_word_length': 4.15668202764977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7231129', 'n_tokens_mistral': 345, 'n_tokens_neox': 343, 'n_words': 92}