Refactored OEmbed service into a proper service

This allows us to share the implementation with other parts of the codebase, the
specific usecase here being fetching the metadata from webmention sources, for
display in the mentions UI, which will be borrowing a lot of stuff from the
bookmark card.
This commit is contained in:
Fabien "egg" O'Carroll 2023-01-18 14:38:08 +07:00
parent a7eeb8f628
commit d0d45d45bc
6 changed files with 27 additions and 23 deletions

View File

@ -1,25 +1,4 @@
const config = require('../../../shared/config');
const externalRequest = require('../../lib/request-external');
const OEmbed = require('@tryghost/oembed-service');
const oembed = new OEmbed({config, externalRequest});
const NFT = require('../../services/nft-oembed');
const nft = new NFT({
config: {
apiKey: config.get('opensea').privateReadOnlyApiKey
}
});
const Twitter = require('../../services/twitter-embed');
const twitter = new Twitter({
config: {
bearerToken: config.get('twitter').privateReadOnlyToken
}
});
oembed.registerProvider(nft);
oembed.registerProvider(twitter);
const oembed = require('../../services/oembed');
module.exports = {
docName: 'oembed',

View File

@ -0,0 +1 @@
module.exports = require('./service');

View File

@ -0,0 +1,24 @@
const config = require('../../../shared/config');
const externalRequest = require('../../lib/request-external');
const OEmbed = require('@tryghost/oembed-service');
const oembed = new OEmbed({config, externalRequest});
const NFT = require('./nft-oembed');
const nft = new NFT({
config: {
apiKey: config.get('opensea').privateReadOnlyApiKey
}
});
const Twitter = require('./twitter-embed');
const twitter = new Twitter({
config: {
bearerToken: config.get('twitter').privateReadOnlyToken
}
});
oembed.registerProvider(nft);
oembed.registerProvider(twitter);
module.exports = oembed;

View File

@ -1,5 +1,5 @@
const assert = require('assert');
const NFTOembedProvider = require('../../../../core/server/services/nft-oembed');
const NFTOembedProvider = require('../../../../../core/server/services/oembed/nft-oembed');
describe('NFTOEmbedProvider', function () {
it('Can support requests for OpenSea Ethereum NTFs', async function () {