-
-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: muti-channel related problems #68
Conversation
我没太理解 |
因为现在的 channel 识别符为 channel 的 name 字段,所以使用原先诸如 |
哦确实,不过需要加的接口应该是用于获取用户的通道列表。
…---Original---
From: ***@***.***>
Date: Sat, May 6, 2023 18:12 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [songquanpeng/message-pusher] fix: muti-channel related problems(PR #68)
此处目前是有 bug 的,使用 option 列表中的设置在请求 push 消息接口时会返回{"message":"无效的渠道名称:wechat_corp","success":false} 因此需要将下拉框的内容替换为 /api/channel/short 返回的内容
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
|
我感觉没有必要专门定义一个接口和结构体。 目前打算在 |
新建结构体是按照 gorm 官方的指南写的 Smart Select Fields |
这样,看来有必要找个时间读完官方文档看一下有没有漏掉的最佳实践。 |
@@ -67,6 +74,11 @@ func GetChannelsByUserId(userId int, startIdx int, num int) (channels []*Channel | |||
return channels, err | |||
} | |||
|
|||
func GetBriefChannelsByUserId(userId int) (channels []*BriefChannel, err error) { | |||
err = DB.Model(&Channel{}).Select("id", "name", "description").Where("user_id = ? and status = ?", userId, common.ChannelStatusEnabled).Find(&channels).Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一小段或许是可以删掉的?.Select("id", "name", "description")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实,不过应该不影响性能。
web/src/helpers/render.js
Outdated
@@ -20,6 +20,13 @@ export function renderChannel(key) { | |||
</Label> | |||
); | |||
} | |||
if (key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里要加个判断,不然消息历史页面会显示未知通道,简单方法就直接把 key 打上去,如果要加背景颜色的话可能还是得调 API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么会显示未知通道?历史消息的通道类型必然是系统里已有的呀。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我发现这个问题了,问题不是出在这里,而是通道的类型没有传给前端。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实还是你的方法简单直接,先这样搞算了哈哈哈,又不是不能用。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/api/message/?p=0
这个接口的返回 channel
是什么呢?对,是用户自定义的通道名,那这个通道名会在你的CHANNEL_OPTIONS
里吗?不会😅!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是这样的,v0.4
版本改动后确实忘记处理这里了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接渲染就好了:
<Table.Cell>
<Label>{message.channel}</Label>
</Table.Cell>
就不走 renderChannel 了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,确实是个好主意
/api/channel/short
接口仍存在的问题:
/api/channel/short
,把选项替换掉就行了,我不怎么会写 react,大佬就交给你啦😜message-pusher/web/src/components/PushSetting.js
Lines 83 to 100 in 9e9f643