From 9b03781c733f3140747bfe233228d947ecb476ee Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Mon, 6 Apr 2020 21:00:21 -0400 Subject: [PATCH] retrieving pleroma remote statuses --- .../stream/thread/thread.component.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index 9c48daa3..7f1e5a3f 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, OnDestroy, Input, Output, EventEmitter, ViewChildren, QueryList, ViewChild, ElementRef } from '@angular/core'; -import { HttpErrorResponse } from '@angular/common/http'; +import { HttpErrorResponse, HttpClient, HttpHeaders } from '@angular/common/http'; import { Subscription } from 'rxjs'; import { MastodonWrapperService } from '../../../services/mastodon-wrapper.service'; @@ -51,6 +51,7 @@ export class ThreadComponent implements OnInit, OnDestroy { private goToTopSubscription: Subscription; constructor( + private readonly httpClient: HttpClient, private readonly notificationService: NotificationService, private readonly toolsService: ToolsService, private readonly mastodonService: MastodonWrapperService) { } @@ -199,19 +200,21 @@ export class ThreadComponent implements OnInit, OnDestroy { }); } - private retrieveRemoteThread(status: Status) { + private async retrieveRemoteThread(status: Status) { try { - console.warn(status); - let splitUrl = status.url.replace('https://', '').split('/'); + let url = status.url; + let splitUrl = url.replace('https://', '').split('/'); let id = splitUrl[splitUrl.length - 1]; let instance = splitUrl[0]; - console.warn(id); - console.warn(instance); - this.mastodonService.getRemoteStatusContext(instance, id) - .then((context: Context) => { - console.warn(context); - }) - .catch(() => { }); + + //Pleroma + if(url.includes('/objects/')){ + var webpage = await this.httpClient.get(url, { responseType: 'text' }).toPromise(); + id = webpage.split(`