feat: relay reviews
This commit is contained in:
@@ -459,6 +459,22 @@ export function createReportDraftEvent(event: Event, reason: string): TDraftEven
|
||||
}
|
||||
}
|
||||
|
||||
export function createRelayReviewDraftEvent(
|
||||
relay: string,
|
||||
review: string,
|
||||
stars: number
|
||||
): TDraftEvent {
|
||||
return {
|
||||
kind: ExtendedKind.RELAY_REVIEW,
|
||||
content: review,
|
||||
tags: [
|
||||
['d', relay],
|
||||
['rating', (stars / 5).toString()]
|
||||
],
|
||||
created_at: dayjs().unix()
|
||||
}
|
||||
}
|
||||
|
||||
function generateImetaTags(imageUrls: string[]) {
|
||||
return imageUrls
|
||||
.map((imageUrl) => {
|
||||
|
||||
@@ -369,3 +369,14 @@ export function getEmojisFromEvent(event: Event): TEmoji[] {
|
||||
|
||||
return emojis
|
||||
}
|
||||
|
||||
export function getStarsFromRelayReviewEvent(event: Event): number {
|
||||
const ratingTag = event.tags.find((t) => t[0] === 'rating')
|
||||
if (ratingTag) {
|
||||
const stars = parseFloat(ratingTag[1]) * 5
|
||||
if (stars > 0 && stars <= 5) {
|
||||
return stars
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ export const toGeneralSettings = () => '/settings/general'
|
||||
export const toTranslation = () => '/settings/translation'
|
||||
export const toProfileEditor = () => '/profile-editor'
|
||||
export const toRelay = (url: string) => `/relays/${encodeURIComponent(url)}`
|
||||
export const toRelayReviews = (url: string) => `/relays/${encodeURIComponent(url)}/reviews`
|
||||
export const toMuteList = () => '/mutes'
|
||||
|
||||
export const toChachiChat = (relay: string, d: string) => {
|
||||
|
||||
Reference in New Issue
Block a user