DEV: Add compatibility with the Glimmer Post Stream (#1230)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { isGPTBot } from "../../lib/ai-bot-helper";
|
||||
|
||||
export default class AiPersonaFlair extends Component {
|
||||
static shouldRender(args) {
|
||||
return isGPTBot(args.post.user);
|
||||
}
|
||||
|
||||
<template>
|
||||
<span class="persona-flair">
|
||||
{{@outletArgs.post.topic.ai_persona_name}}
|
||||
</span>
|
||||
</template>
|
||||
}
|
||||
@@ -1,11 +1,29 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { getOwnerWithFallback } from "discourse/lib/get-owner";
|
||||
import Composer from "discourse/models/composer";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import ShareFullTopicModal from "../components/modal/share-full-topic-modal";
|
||||
|
||||
const MAX_PERSONA_USER_ID = -1200;
|
||||
|
||||
let enabledChatBotIds;
|
||||
|
||||
export function isGPTBot(user) {
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!enabledChatBotIds) {
|
||||
const currentUser = getOwnerWithFallback(this).lookup(
|
||||
"service:current-user"
|
||||
);
|
||||
enabledChatBotIds = currentUser.ai_enabled_chat_bots.map((bot) => bot.id);
|
||||
}
|
||||
|
||||
return enabledChatBotIds.includes(user.id);
|
||||
}
|
||||
|
||||
export function isPostFromAiBot(post, currentUser) {
|
||||
return (
|
||||
post.user_id <= MAX_PERSONA_USER_ID ||
|
||||
|
||||
Reference in New Issue
Block a user