mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 06:52:24 +08:00
8163b52301
* Flag users as "Always premoderate" Status can be set using the action dropdown in the People tab and in User Details. Users flagged as "Always premoderate" will have their comments sent to the premod queue. Users can be filtered with the Always Premoderate status. Include Always Premoderate status changes in User History. Add spanish translations. * Reorder CSS as per cvle's suggestion * Address second comment
94 lines
1.9 KiB
JavaScript
94 lines
1.9 KiB
JavaScript
import get from 'lodash/get';
|
|
import moment from 'moment';
|
|
|
|
/**
|
|
* getReliability
|
|
* retrieves reliability value as string
|
|
*/
|
|
|
|
export const getReliability = reliabilityValue => {
|
|
if (reliabilityValue === null) {
|
|
return 'neutral';
|
|
} else if (reliabilityValue) {
|
|
return 'reliable';
|
|
} else {
|
|
return 'unreliable';
|
|
}
|
|
};
|
|
|
|
/**
|
|
* isSuspended
|
|
* retrieves boolean based on the user suspension status
|
|
*/
|
|
|
|
export const isSuspended = user => {
|
|
const suspensionUntil = get(user, 'state.status.suspension.until');
|
|
return user && suspensionUntil && new Date(suspensionUntil) > new Date();
|
|
};
|
|
|
|
/**
|
|
* isBanned
|
|
* retrieves boolean based on the user ban status
|
|
*/
|
|
|
|
export const isBanned = user => {
|
|
return get(user, 'state.status.banned.status');
|
|
};
|
|
|
|
/**
|
|
* isAlwaysPremod
|
|
* retrieves boolean based on the user premod status
|
|
*/
|
|
|
|
export const isAlwaysPremod = user => {
|
|
return get(user, 'state.status.alwaysPremod.status');
|
|
};
|
|
|
|
/**
|
|
* isUsernameRejected
|
|
* retrieves boolean based on the username status
|
|
*/
|
|
|
|
export const isUsernameRejected = user => {
|
|
return get(user, 'state.status.username.status') === 'REJECTED';
|
|
};
|
|
|
|
/**
|
|
* isUsernameChanged
|
|
* retrieves boolean based on the username status
|
|
*/
|
|
|
|
export const isUsernameChanged = user => {
|
|
return get(user, 'state.status.username.status') === 'CHANGED';
|
|
};
|
|
|
|
/**
|
|
* canUsernameBeUpdated
|
|
* retrieves boolean whether a username can be updated or not
|
|
*/
|
|
|
|
export const canUsernameBeUpdated = status => {
|
|
const oldestEditTime = moment()
|
|
.subtract(14, 'days')
|
|
.toDate();
|
|
|
|
return !status.username.history.some(({ created_at }) =>
|
|
moment(created_at).isAfter(oldestEditTime)
|
|
);
|
|
};
|
|
|
|
/**
|
|
* getKarma
|
|
* retrieves karma value as string
|
|
*/
|
|
|
|
export const getKarma = reliability => {
|
|
if (reliability === null) {
|
|
return 'neutral';
|
|
} else if (reliability) {
|
|
return 'good';
|
|
} else {
|
|
return 'bad';
|
|
}
|
|
};
|