mirror of
https://github.com/wassname/talk.git
synced 2026-08-07 11:29:44 +08:00
* feat: initial toxic comments impl * feat: improved logging * feat: tenant cache adapter * feat: move more types into graphql
23 lines
590 B
TypeScript
23 lines
590 B
TypeScript
import { get } from "lodash";
|
|
|
|
import { GQLKarmaThresholds } from "talk-server/graph/tenant/schema/__generated__/types";
|
|
import { User } from "talk-server/models/user";
|
|
|
|
export const getCommentTrustScore = (user: User): number =>
|
|
get(user, "metadata.trust.comment.karma", 0);
|
|
|
|
export const isReliableCommenter = (
|
|
thresholds: GQLKarmaThresholds,
|
|
user: User
|
|
): boolean | null => {
|
|
const score = getCommentTrustScore(user);
|
|
|
|
if (score >= thresholds.comment.reliable) {
|
|
return true;
|
|
} else if (score <= thresholds.comment.unreliable) {
|
|
return false;
|
|
}
|
|
|
|
return null;
|
|
};
|