Public Source Viewer
비나래아카이브 개발자 포털
실제 서비스 구조를 살펴볼 수 있는 공개용 코드 뷰어입니다. 인증, 세션, 외부 연동, 토큰, 관리자 식별 등 보안상 민감한 구현은 파일 단위 또는 줄 단위로 검열됩니다.
src/services/post.service.ts
공개 가능
1
export function getBinaraeStatus(posts: any[]): string {
2
const allTimestamps: Date[] = [];
3
4
posts.forEach(post => {
5
[SECURITY REDACTED] 민감한 설정/인증/토큰 관련 코드입니다.
6
allTimestamps.push(new Date(post.timestamp));
7
}
8
if (post.replies) {
9
post.replies.forEach((reply: any) => {
10
[SECURITY REDACTED] 민감한 설정/인증/토큰 관련 코드입니다.
11
allTimestamps.push(new Date(reply.timestamp));
12
}
13
});
14
}
15
});
16
17
if (allTimestamps.length === 0) {
18
return '아직 활동한 내역이 없어요.';
19
}
20
21
allTimestamps.sort((a, b) => b.getTime() - a.getTime());
22
const latest = allTimestamps[0];
23
const now = new Date();
24
const diff = now.getTime() - latest.getTime();
25
const hours = Math.floor(diff / (1000 * 60 * 60));
26
const days = Math.floor(hours / 24);
27
28
if (days > 0) {
29
return `${days}일 전에 활동했어요.`;
30
} else if (hours > 0) {
31
return `${hours}시간 전에 활동했어요.`;
32
} else {
33
return '방금 전에 활동했어요.';
34
}
35
}
36