Skip to content

Commit

Permalink
linter warnings regarding usage of any
Browse files Browse the repository at this point in the history
  • Loading branch information
pxpm committed Oct 24, 2024
1 parent abbdc77 commit ffedf0a
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions infrastructure/service/lemmyContentAggregatorService.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
import Post from "../../domain/service/contentAggregatorService/post";
import ContentAggregatorService from "../../domain/service/contentAggregatorService/contentAggregatorService";

interface LemmyPostAuthor {
display_name: string;
name: string;
}

interface LemmyPostData {
featured_community: boolean;
featured_local: boolean;
name: string;
ap_id: string;
body: string;
published: string;
}

interface LemmyPost {
creator: LemmyPostAuthor;
post: LemmyPostData;
}

interface LemmyApiResponse {
posts: LemmyPost[];
}

export default class LemmyContentAggregatorService implements ContentAggregatorService {
private feedUrl = "https://lemmy.pt/api/v3/post/list?community_name=devpt&limit=10&page=1&sort=New";

async fetchLastPosts(): Promise<Post[]> {
let unpinnedPosts = [];
let unpinnedPosts: Post[] = [];

try {
const response = await fetch(this.feedUrl);

const data = await response.json();
const data: LemmyApiResponse = await response.json();

unpinnedPosts = data.posts
.filter((item: any) => !item.post.featured_community && !item.post.featured_local)
.filter((item: LemmyPost) => !item.post.featured_community && !item.post.featured_local)
.map(
(item: any) =>
(item: LemmyPost) =>
new Post({
authorName: item.creator.display_name || item.creator.name,
title: item.post.name,
Expand Down

0 comments on commit ffedf0a

Please sign in to comment.