mirror of
https://github.com/wassname/talk.git
synced 2026-08-07 11:29:44 +08:00
server side
This commit is contained in:
@@ -245,9 +245,12 @@ class UserDetail extends React.Component {
|
||||
<KarmaTooltip />
|
||||
</div>
|
||||
<span
|
||||
className={cn(styles.statKarmaResult, styles[getKarma(100)])}
|
||||
className={cn(
|
||||
styles.statKarmaResult,
|
||||
styles[getKarma(user.reliable.commenter)]
|
||||
)}
|
||||
>
|
||||
{100}
|
||||
{user.reliable.commenterScore}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -185,6 +185,8 @@ export const withUserDetailQuery = withQuery(
|
||||
}
|
||||
reliable {
|
||||
flagger
|
||||
commenter
|
||||
commenterScore
|
||||
}
|
||||
state {
|
||||
status {
|
||||
|
||||
@@ -55,10 +55,10 @@ export const canUsernameBeUpdated = status => {
|
||||
* retrieves karma value as string
|
||||
*/
|
||||
|
||||
export const getKarma = score => {
|
||||
if (score === 0) {
|
||||
export const getKarma = reliability => {
|
||||
if (reliability === null) {
|
||||
return 'neutral';
|
||||
} else if (score) {
|
||||
} else if (reliability) {
|
||||
return 'good';
|
||||
} else {
|
||||
return 'bad';
|
||||
|
||||
@@ -20,9 +20,17 @@ type Reliability {
|
||||
# `null` if the reliability cannot be determined.
|
||||
flagger: Boolean
|
||||
|
||||
# flaggerScore will contains the number of agreed flags vs disagred flag
|
||||
# count.
|
||||
flaggerScore: Int!
|
||||
|
||||
# Commenter will be `true` when the commenter is reliable, `false` if not, or
|
||||
# `null` if the reliability cannot be determined.
|
||||
commenter: Boolean
|
||||
|
||||
# commenterScore the number of approved comments (not untouched) subtracted by
|
||||
# the number of rejected comments.
|
||||
commenterScore: Int!
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const debug = require('debug')('talk:services:karma');
|
||||
const UserModel = require('../models/user');
|
||||
const { TRUST_THRESHOLDS } = require('../config');
|
||||
const { get } = require('lodash');
|
||||
|
||||
/**
|
||||
* This will create an object with the property name of the action type as the
|
||||
@@ -83,9 +84,17 @@ class KarmaModel {
|
||||
return KarmaService.isReliable('flag', this.model);
|
||||
}
|
||||
|
||||
get flaggerScore() {
|
||||
return get(this.model, 'flag.karma', 0);
|
||||
}
|
||||
|
||||
get commenter() {
|
||||
return KarmaService.isReliable('comment', this.model);
|
||||
}
|
||||
|
||||
get commenterScore() {
|
||||
return get(this.model, 'comment.karma', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user