Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 20, 2024
2 parents eaac274 + c5ac8b1 commit c431fa6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# Changelog

### [Version 1.19.9](https://github.com/lobehub/lobe-chat/compare/v1.19.8...v1.19.9)

<sup>Released on **2024-09-20**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix a bug with server agent config when user not exist.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

- **misc**: Fix a bug with server agent config when user not exist, closes [#4034](https://github.com/lobehub/lobe-chat/issues/4034) ([f6a232b](https://github.com/lobehub/lobe-chat/commit/f6a232b))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.19.8](https://github.com/lobehub/lobe-chat/compare/v1.19.7...v1.19.8)

<sup>Released on **2024-09-19**</sup>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.19.8",
"version": "1.19.9",
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
"keywords": [
"framework",
Expand Down
1 change: 1 addition & 0 deletions src/app/api/webhooks/clerk/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const POST = async (req: Request): Promise<NextResponse> => {
const userService = new UserService();
switch (type) {
case 'user.created': {
pino.info('creating user due to clerk webhook');
return userService.createUser(data.id, data);
}
case 'user.deleted': {
Expand Down
6 changes: 6 additions & 0 deletions src/server/routers/lambda/agent.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { z } from 'zod';

import { INBOX_SESSION_ID } from '@/const/session';
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
import { AgentModel } from '@/database/server/models/agent';
import { FileModel } from '@/database/server/models/file';
import { KnowledgeBaseModel } from '@/database/server/models/knowledgeBase';
import { SessionModel } from '@/database/server/models/session';
import { UserModel } from '@/database/server/models/user';
import { pino } from '@/libs/logger';
import { authedProcedure, router } from '@/libs/trpc';
import { KnowledgeItem, KnowledgeType } from '@/types/knowledgeBase';
Expand Down Expand Up @@ -84,6 +86,10 @@ export const agentRouter = router({
const item = await ctx.sessionModel.findByIdOrSlug(INBOX_SESSION_ID);
// if there is no session for user, create one
if (!item) {
// if there is no user, return default config
const user = await UserModel.findById(ctx.userId);
if (!user) return DEFAULT_AGENT_CONFIG;

const res = await ctx.sessionModel.createInbox();
pino.info('create inbox session', res);
}
Expand Down
2 changes: 0 additions & 2 deletions src/server/services/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { pino } from '@/libs/logger';

export class UserService {
createUser = async (id: string, params: UserJSON) => {
pino.info('creating user due to clerk webhook');

// Check if user already exists
const res = await UserModel.findById(id);

Expand Down

0 comments on commit c431fa6

Please sign in to comment.