Skip to content

Commit

Permalink
feat: post feed supports LIVE_SHARE
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed May 3, 2022
1 parent 90388c1 commit 4a36251
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/command/post/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,25 @@ const viewFeeds = async (opts: FeedOptions) => {
async function renderPost(p: Entity.FollowingUpdate) {
const texts: string[] = []
if (p.type === 'PERSONAL_UPDATE') {
texts.push(`${displayUsers(p.users)} 关注了 ${displayUsers(p.targetUsers)}`)
switch (p.action) {
case 'LIVE_SHARE':
texts.push(
// @ts-expect-error
`${displayUsers(p.users)} ${p.verb}`,
// @ts-expect-error
(await displayImage(p.live.picture.picUrl)).result,
// @ts-expect-error
p.live.title
)
break
case 'USER_FOLLOW':
texts.push(
`${displayUsers(p.users)} 关注了 ${displayUsers(p.targetUsers)}`
)
break
default:
texts.push(`unsupported action: ${p.action}`)
}
} else if (p.type === 'ORIGINAL_POST') {
const link = isMacOS
? logger.colors.gray(
Expand All @@ -63,7 +81,7 @@ async function renderPost(p: Entity.FollowingUpdate) {
if (p.pictures && p.pictures.length > 0) {
const images = await Promise.all(
p.pictures.map((p) =>
displayImage(p.middlePicUrl).then(({ result }) => result)
displayImage(p.middlePicUrl).then(({ result }) => `${result}\n`)
)
)
texts.push(...images)
Expand Down

0 comments on commit 4a36251

Please sign in to comment.