Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linter warnings regarding usage of any #77

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading