Pass config so images render with correct media repo
This commit is contained in:
parent
a49657f9e3
commit
1c7c6bf440
|
@ -4,7 +4,7 @@ const fetch = require('node-fetch');
|
|||
const { matrixServerUrl } = require('../config.json');
|
||||
const secrets = require('../secrets.json');
|
||||
|
||||
const matrixAccessToken = secrets['matrix-access-token'];
|
||||
const matrixAccessToken = secrets.matrixAccessToken;
|
||||
assert(matrixAccessToken);
|
||||
|
||||
class HTTPResponseError extends Error {
|
||||
|
@ -44,8 +44,6 @@ async function fetchEventsForTimestamp(roomId, ts) {
|
|||
matrixServerUrl,
|
||||
`_matrix/client/unstable/org.matrix.msc3030/rooms/${roomId}/timestamp_to_event?ts=${ts}&dir=f`
|
||||
);
|
||||
console.log('timestampToEventEndpoint', timestampToEventEndpoint);
|
||||
|
||||
const timestampToEventResData = await fetchEndpoint(timestampToEventEndpoint);
|
||||
//console.log('timestampToEventResData', timestampToEventResData);
|
||||
|
||||
|
@ -61,11 +59,12 @@ async function fetchEventsForTimestamp(roomId, ts) {
|
|||
|
||||
const messagesEndpoint = path.join(
|
||||
matrixServerUrl,
|
||||
`_matrix/client/r0/rooms/${roomId}/messages?from=${contextResData.start}&limit=100&filter={"lazy_load_members":true,"include_redundant_members":true}`
|
||||
`_matrix/client/r0/rooms/${roomId}/messages?from=${contextResData.start}&limit=50&filter={"lazy_load_members":true,"include_redundant_members":true}`
|
||||
);
|
||||
const messageResData = await fetchEndpoint(messagesEndpoint);
|
||||
//console.log('messageResData', messageResData);
|
||||
|
||||
//console.log('messageResData.state', messageResData.state);
|
||||
const stateEventMap = {};
|
||||
for (const stateEvent of messageResData.state) {
|
||||
if (stateEvent.type === 'm.room.member') {
|
||||
|
|
|
@ -13,6 +13,14 @@ const {
|
|||
TimelineView,
|
||||
} = require('hydrogen-view-sdk');
|
||||
|
||||
const events = global.INPUT_EVENTS;
|
||||
assert(events);
|
||||
const stateEventMap = global.INPUT_STATE_EVENT_MAP;
|
||||
assert(stateEventMap);
|
||||
const config = global.INPUT_CONFIG;
|
||||
assert(config);
|
||||
assert(config.matrixServerUrl);
|
||||
|
||||
let eventIndexCounter = 0;
|
||||
const fragmentIdComparer = new FragmentIdComparer([]);
|
||||
function makeEventEntryFromEventJson(eventJson, memberEvent) {
|
||||
|
@ -40,17 +48,13 @@ function makeEventEntryFromEventJson(eventJson, memberEvent) {
|
|||
}
|
||||
|
||||
async function mountHydrogen() {
|
||||
const events = global.INPUT_EVENTS;
|
||||
assert(events);
|
||||
const stateEventMap = global.INPUT_STATE_EVENT_MAP;
|
||||
assert(stateEventMap);
|
||||
|
||||
const app = document.querySelector('#app');
|
||||
|
||||
const config = {};
|
||||
const platformConfig = {};
|
||||
const assetPaths = {};
|
||||
const platform = new Platform(app, assetPaths, config, { development: true });
|
||||
const platform = new Platform(app, assetPaths, platformConfig, { development: true });
|
||||
|
||||
// We use the timeline to setup the relations between entries
|
||||
const timeline = new Timeline({
|
||||
roomId: roomId,
|
||||
//storage: this._storage,
|
||||
|
@ -65,7 +69,7 @@ async function mountHydrogen() {
|
|||
roomVM: {
|
||||
room: {
|
||||
mediaRepository: new MediaRepository({
|
||||
homeserver: 'https://matrix-client.matrix.org',
|
||||
homeserver: config.matrixServerUrl,
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
@ -97,6 +101,7 @@ async function mountHydrogen() {
|
|||
timeline._setupEntries([]);
|
||||
// Make it safe to iterate a derived observable collection
|
||||
timeline.entries.subscribe({ onAdd: () => null, onUpdate: () => null });
|
||||
// We use the timeline to setup the relations between entries
|
||||
timeline.addEntries(eventEntries);
|
||||
|
||||
//console.log('timeline.entries', timeline.entries.length, timeline.entries);
|
||||
|
|
|
@ -5,6 +5,8 @@ const { readFile } = require('fs').promises;
|
|||
const crypto = require('crypto');
|
||||
const { parseHTML } = require('linkedom');
|
||||
|
||||
const config = require('../config.json');
|
||||
|
||||
async function renderToString(events, stateEventMap) {
|
||||
assert(events);
|
||||
assert(stateEventMap);
|
||||
|
@ -40,6 +42,7 @@ async function renderToString(events, stateEventMap) {
|
|||
|
||||
vmContext.global.INPUT_EVENTS = events;
|
||||
vmContext.global.INPUT_STATE_EVENT_MAP = stateEventMap;
|
||||
vmContext.global.INPUT_CONFIG = config;
|
||||
|
||||
const hydrogenRenderScriptCode = await readFile(
|
||||
path.resolve(__dirname, './hydrogen-vm-render-script.js'),
|
||||
|
|
Loading…
Reference in New Issue