Skip to content

Commit

Permalink
Merge branch 'beta' into x/gorm
Browse files Browse the repository at this point in the history
  • Loading branch information
alimy committed Oct 2, 2023
2 parents 267ec79 21ba209 commit 0d3fda7
Show file tree
Hide file tree
Showing 57 changed files with 423 additions and 98 deletions.
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 158,31 @@ All notable changes to paopao-ce are documented in this file.
UNION
SELECT user_id, follow_id he_uid, 10 AS style
FROM p_following WHERE is_del=0;
```
- add tweets count info in Home/Profile page.
- add custom web frontend features base by a profile that fetch from backend support.
can add custom config to conf.yaml to custom web frontend features:
```yaml
...
WebProfile:
UseFriendship: true # 前端是否使用好友体系
EnableTrendsBar: true # 广场页面是否开启动态条栏功能
EnableWallet: false # 是否开启钱包功能
AllowTweetAttachment: true # 是否允许推文附件
AllowTweetAttachmentPrice: true # 是否允许推文付费附件
AllowTweetVideo: true # 是否允许视频推文
AllowUserRegister: true # 是否允许用户注册
AllowPhoneBind: true # 是否允许手机绑定
DefaultTweetVisibility: friend # 推文可见性,默认好友可见 值: public/following/friend/private
DefaultMsgLoopInterval: 5000 # 拉取未读消息的间隔,单位:毫秒, 默认5000ms
CopyrightTop: "2023 paopao.info"
CopyrightLeft: "Roc's Me"
CopyrightLeftLink: ""
CopyrightRight: "泡泡(PaoPao)开源社区"
CopyrightRightLink: "https://www.paopao.info"
...
```
## 0.4.2
### Fixed
- fixed remove multi-objects no effects and occurs resource leak error when use Minio as OSS(Object Storage System).[#371](https://github.com/rocboss/paopao-ce/pull/371) [#372](https://github.com/rocboss/paopao-ce/pull/372)
Expand Down
63 changes: 63 additions & 0 deletions auto/api/v1/site.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions config.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 183,20 @@ Sqlite3: # Sqlite3数据库
Redis:
InitAddress:
- redis:6379
WebProfile:
UseFriendship: true # 前端是否使用好友体系
EnableTrendsBar: true # 广场页面是否开启动态条栏功能
EnableWallet: false # 是否开启钱包功能
AllowTweetAttachment: true # 是否允许推文附件
AllowTweetAttachmentPrice: true # 是否允许推文付费附件
AllowTweetVideo: true # 是否允许视频推文
AllowUserRegister: true # 是否允许用户注册
AllowPhoneBind: true # 是否允许手机绑定
DefaultTweetVisibility: friend # 推文可见性,默认好友可见 值: public/following/friend/private
DefaultMsgLoopInterval: 5000 # 拉取未读消息的间隔,单位:毫秒, 默认5000ms
CopyrightTop: "2023 paopao.info"
CopyrightLeft: "Roc's Me"
CopyrightLeftLink: ""
CopyrightRight: "泡泡(PaoPao)开源社区"
CopyrightRightLink: "https://www.paopao.info"

2 changes: 2 additions & 0 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 57,7 @@ var (
S3Setting *s3Conf
LocalOSSSetting *localossConf
JWTSetting *jwtConf
WebProfileSetting *WebProfileConf
)

func setupSetting(suite []string, noDefault bool) error {
Expand Down Expand Up @@ -117,6 118,7 @@ func setupSetting(suite []string, noDefault bool) error {
"MinIO": &MinIOSetting,
"LocalOSS": &LocalOSSSetting,
"S3": &S3Setting,
"WebProfile": &WebProfileSetting,
}
for k, v := range objects {
err := vp.UnmarshalKey(k, v)
Expand Down
27 changes: 21 additions & 6 deletions internal/conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 13,12 @@ Cache:
UnreadMsgExpire: 60 # 未读消息过期时间,单位秒, 默认60s
UserTweetsExpire: 60 # 获取用户推文列表过期时间,单位秒, 默认60s
IndexTweetsExpire: 120 # 获取广场推文列表过期时间,单位秒, 默认120s
TweetCommentsExpire: 180 # 获取推文评论过期时间,单位秒, 默认180s
IndexTrendsExpire: 300 # 获取广场动态信息过期时间,单位秒, 默认300s
TweetCommentsExpire: 120 # 获取推文评论过期时间,单位秒, 默认120s
IndexTrendsExpire: 120 # 获取广场动态信息过期时间,单位秒, 默认120s
OnlineUserExpire: 300 # 标记在线用户 过期时间,单位秒, 默认300s
UserInfoExpire: 300 # 获取用户信息过期时间,单位秒, 默认300s
UserProfileExpire: 180 # 获取用户概要过期时间,单位秒, 默认180s
UserRelationExpire: 600 # 用户关系信息过期时间,单位秒, 默认600s
UserInfoExpire: 120 # 获取用户信息过期时间,单位秒, 默认120s
UserProfileExpire: 120 # 获取用户概要过期时间,单位秒, 默认120s
UserRelationExpire: 120 # 用户关系信息过期时间,单位秒, 默认120s
MessagesExpire: 60 # 消息列表过期时间,单位秒, 默认60s
EventManager: # 事件管理器的配置参数
MinWorker: 64 # 最小后台工作者, 设置范围[5, ], 默认64
Expand Down Expand Up @@ -248,4 248,19 @@ Redis:
Password:
SelectDB:
ConnWriteTimeout: 60 # 连接写超时时间 多少秒 默认 60秒

WebProfile:
UseFriendship: true # 前端是否使用好友体系
EnableTrendsBar: true # 广场页面是否开启动态条栏功能
EnableWallet: false # 是否开启钱包功能
AllowTweetAttachment: true # 是否允许推文附件
AllowTweetAttachmentPrice: true # 是否允许推文付费附件
AllowTweetVideo: true # 是否允许视频推文
AllowUserRegister: true # 是否允许用户注册
AllowPhoneBind: true # 是否允许手机绑定
DefaultTweetVisibility: friend # 推文可见性,默认好友可见 值: public/following/friend/private
DefaultMsgLoopInterval: 5000 # 拉取未读消息的间隔,单位:毫秒, 默认5000ms
CopyrightTop: "2023 paopao.info"
CopyrightLeft: "Roc's Me"
CopyrightLeftLink: ""
CopyrightRight: "泡泡(PaoPao)开源社区"
CopyrightRightLink: "https://www.paopao.info"
18 changes: 18 additions & 0 deletions internal/conf/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 283,24 @@ type jwtConf struct {
Expire time.Duration
}

type WebProfileConf struct {
UseFriendship bool `json:"use_friendship"`
EnableTrendsBar bool `json:"enable_trends_bar"`
EnableWallet bool `json:"enable_wallet"`
AllowTweetAttachment bool `json:"allow_tweet_attachment"`
AllowTweetAttachmentPrice bool `json:"allow_tweet_attachment_price"`
AllowTweetVideo bool `json:"allow_tweet_video"`
AllowUserRegister bool `json:"allow_user_register"`
AllowPhoneBind bool `json:"allow_phone_bind"`
DefaultTweetVisibility string `json:"default_tweet_visibility"`
DefaultMsgLoopInterval int `json:"default_msg_loop_interval"`
CopyrightTop string `json:"copyright_top"`
CopyrightLeft string `json:"copyright_left"`
CopyrightLeftLink string `json:"copyright_left_link"`
CopyrightRight string `json:"copyright_right"`
CopyrightRightLink string `json:"copyright_right_link"`
}

func (s *httpServerConf) GetReadTimeout() time.Duration {
return s.ReadTimeout * time.Second
}
Expand Down
8 changes: 0 additions & 8 deletions internal/model/web/pub.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 4,6 @@

package web

import (
"github.com/rocboss/paopao-ce/pkg/version"
)

type GetCaptchaResp struct {
Id string `json:"id"`
Content string `json:"b64s"`
Expand All @@ -19,10 15,6 @@ type SendCaptchaReq struct {
ImgCaptchaID string `json:"img_captcha_id" form:"img_captcha_id" binding:"required"`
}

type VersionResp struct {
BuildInfo *version.BuildInfo `json:"build_info"`
}

type LoginReq struct {
Username string `json:"username" form:"username" binding:"required"`
Password string `json:"password" form:"password" binding:"required"`
Expand Down
16 changes: 16 additions & 0 deletions internal/model/web/site.go
Original file line number Diff line number Diff line change
@@ -0,0 1,16 @@
// Copyright 2023 ROC. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package web

import (
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/rocboss/paopao-ce/pkg/version"
)

type VersionResp struct {
BuildInfo *version.BuildInfo `json:"build_info"`
}

type SiteProfileResp = conf.WebProfileConf
39 changes: 39 additions & 0 deletions internal/servants/web/site.go
Original file line number Diff line number Diff line change
@@ -0,0 1,39 @@
// Copyright 2023 ROC. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package web

import (
"github.com/alimy/mir/v4"
api "github.com/rocboss/paopao-ce/auto/api/v1"
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/rocboss/paopao-ce/internal/model/web"
"github.com/rocboss/paopao-ce/internal/servants/base"
"github.com/rocboss/paopao-ce/pkg/version"
)

var (
_ api.Site = (*siteSrv)(nil)
)

type siteSrv struct {
api.UnimplementedSiteServant
*base.BaseServant
}

func (*siteSrv) Profile() (*web.SiteProfileResp, mir.Error) {
return conf.WebProfileSetting, nil
}

func (*siteSrv) Version() (*web.VersionResp, mir.Error) {
return &web.VersionResp{
BuildInfo: version.ReadBuildInfo(),
}, nil
}

func newSiteSrv() api.Site {
return &siteSrv{
BaseServant: base.NewBaseServant(),
}
}
1 change: 1 addition & 0 deletions internal/servants/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 41,7 @@ func RouteWeb(e *gin.Engine) {
api.RegisterTrendsServant(e, newTrendsSrv(ds))
api.RegisterFollowshipServant(e, newFollowshipSrv(ds))
api.RegisterFriendshipServant(e, newFriendshipSrv(ds))
api.RegisterSiteServant(e, newSiteSrv())
// regster servants if needed by configure
cfg.Be("Alipay", func() {
client := conf.MustAlipayClient()
Expand Down
22 changes: 22 additions & 0 deletions mirc/web/v1/site.go
Original file line number Diff line number Diff line change
@@ -0,0 1,22 @@
package v1

import (
. "github.com/alimy/mir/v4"
. "github.com/alimy/mir/v4/engine"
"github.com/rocboss/paopao-ce/internal/model/web"
)

func init() {
Entry[Site]()
}

// Site 站点本身相关的信息服务
type Site struct {
Group `mir:"v1"`

// Version 获取后台版本信息
Version func(Get) web.VersionResp `mir:"/site/version"`

// Profile 站点配置概要信息
Profile func(Get) web.SiteProfileResp `mir:"/site/profile"`
}
4 changes: 2 additions & 2 deletions web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ VITE_USE_FRIENDSHIP=true
# 模块开启
VITE_ENABLE_ANOUNCEMENT=false
VITE_ENABLE_WALLET=false
VITE_ENABLE_FRIENDS_BAR=true
VITE_ENABLE_TRENDS_BAR=true

# 功能开启
VITE_ALLOW_TWEET_ATTACHMENT=true
Expand All @@ -19,7 19,7 @@ VITE_ALLOW_PHONE_BIND=true

# 局部参数
VITE_DEFAULT_MSG_LOOP_INTERVAL=5000 # 拉取未读消息的间隔,单位:毫秒, 默认5000ms
VITE_DEFAULT_TWEET_VISIBILITY=friend # 推文可见性,默认好友可见
VITE_DEFAULT_TWEET_VISIBILITY=friend # 推文可见性,默认好友可见 值: public/following/friend/private
VITE_DEFAULT_TWEET_MAX_LENGTH=400 # 推文最大长度, 默认400字
VITE_DEFAULT_COMMENT_MAX_LENGTH=300 # 评论最大长度, 默认300字
VITE_DEFAULT_REPLY_MAX_LENGTH=300 # 评论最大长度, 默认300字
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0d3fda7

Please sign in to comment.