Add Activity id if missing

This commit is contained in:
mei23 2018-08-25 13:11:54 +09:00
parent edb61e52c5
commit 92828028db

View file

@ -1,7 +1,16 @@
export default (x: any) => Object.assign({
'@context': [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
{ Hashtag: 'as:Hashtag' }
]
}, x);
import config from '../../../config';
import * as uuid from 'uuid';
export default (x: any) => {
if (x !== null && typeof x === 'object' && x.id == null) {
x.id = `${config.url}/${uuid.v4()}`;
}
return Object.assign({
'@context': [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
{ Hashtag: 'as:Hashtag' }
]
}, x);
};