ディレクトリ再編
This commit is contained in:
parent
cb924ff92b
commit
85d471efbb
45 changed files with 204 additions and 41 deletions
19
src/backend/functions/get-scores.ts
Normal file
19
src/backend/functions/get-scores.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { User } from '../models/entities/user';
|
||||
import { Score } from '../../common/types/score';
|
||||
import { api } from '../services/misskey';
|
||||
import { toSignedString } from './to-signed-string';
|
||||
|
||||
export const getScores = async (user: User): Promise<Score> => {
|
||||
const miUser = await api<Record<string, number>>(user.host, 'users/show', { username: user.username }, user.token);
|
||||
if (miUser.error) {
|
||||
throw miUser.error;
|
||||
}
|
||||
return {
|
||||
notesCount: miUser.notesCount,
|
||||
followingCount: miUser.followingCount,
|
||||
followersCount: miUser.followersCount,
|
||||
notesDelta: toSignedString(miUser.notesCount - user.prevNotesCount),
|
||||
followingDelta: toSignedString(miUser.followingCount - user.prevFollowingCount),
|
||||
followersDelta: toSignedString(miUser.followersCount - user.prevFollowersCount),
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue