|
|
@ -62,16 +62,16 @@ func (s *looseSrv) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) GetUserTweets(req *web.GetUserTweetsReq) (res *web.GetUserTweetsResp, err mir.Error) {
|
|
|
|
func (s *looseSrv) GetUserTweets(req *web.GetUserTweetsReq) (res *web.GetUserTweetsResp, err mir.Error) {
|
|
|
|
isSelf := (req.User != nil && req.User.Username == req.Username)
|
|
|
|
relTyp := s.RelationTypFrom(req.User, req.Username)
|
|
|
|
switch req.Style {
|
|
|
|
switch req.Style {
|
|
|
|
case web.UserPostsStyleComment:
|
|
|
|
case web.UserPostsStyleComment:
|
|
|
|
res, err = s.getUserCommentTweets(req, isSelf)
|
|
|
|
res, err = s.getUserCommentTweets(req, relTyp)
|
|
|
|
case web.UserPostsStyleHighlight:
|
|
|
|
case web.UserPostsStyleHighlight:
|
|
|
|
res, err = s.getUserHighlightTweets(req, isSelf)
|
|
|
|
res, err = s.getUserHighlightTweets(req, relTyp)
|
|
|
|
case web.UserPostsStyleMedia:
|
|
|
|
case web.UserPostsStyleMedia:
|
|
|
|
res, err = s.getUserMediaTweets(req, isSelf)
|
|
|
|
res, err = s.getUserMediaTweets(req, relTyp)
|
|
|
|
case web.UserPostsStyleStar:
|
|
|
|
case web.UserPostsStyleStar:
|
|
|
|
res, err = s.getUserStarTweets(req, isSelf)
|
|
|
|
res, err = s.getUserStarTweets(req, relTyp)
|
|
|
|
case web.UserPostsStylePost:
|
|
|
|
case web.UserPostsStylePost:
|
|
|
|
fallthrough
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -80,33 +80,24 @@ func (s *looseSrv) GetUserTweets(req *web.GetUserTweetsReq) (res *web.GetUserTwe
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) getUserCommentTweets(req *web.GetUserTweetsReq, isSelf bool) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
func (s *looseSrv) getUserCommentTweets(req *web.GetUserTweetsReq, relTyp cs.RelationTyp) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
// TODO: add implement logic
|
|
|
|
// TODO: add implement logic
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) getUserHighlightTweets(req *web.GetUserTweetsReq, isSelf bool) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
func (s *looseSrv) getUserHighlightTweets(req *web.GetUserTweetsReq, relTyp cs.RelationTyp) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
// TODO: add implement logic
|
|
|
|
// TODO: add implement logic
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) getUserMediaTweets(req *web.GetUserTweetsReq, isSelf bool) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
func (s *looseSrv) getUserMediaTweets(req *web.GetUserTweetsReq, relTyp cs.RelationTyp) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
// TODO: add implement logic
|
|
|
|
// TODO: add implement logic
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) getUserStarTweets(req *web.GetUserTweetsReq, isSelf bool) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
|
|
|
|
if isSelf {
|
|
|
|
|
|
|
|
return s.getSelfStarTweets(req)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: add implement logic for not self star tweets
|
|
|
|
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) getSelfCommentTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
func (s *looseSrv) getSelfCommentTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
// TODO: add implement logic
|
|
|
|
// TODO: add implement logic
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
|
resp := base.PageRespFrom(nil, req.Page, req.PageSize, 0)
|
|
|
@ -119,21 +110,25 @@ func (s *looseSrv) getSelfMediaTweets(req *web.GetUserTweetsReq) (*web.GetUserTw
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
return (*web.GetUserTweetsResp)(resp), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *looseSrv) getSelfStarTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
func (s *looseSrv) getUserStarTweets(req *web.GetUserTweetsReq, relTyp cs.RelationTyp) (*web.GetUserTweetsResp, mir.Error) {
|
|
|
|
stars, err := s.Ds.GetUserPostStars(req.User.ID, (req.Page-1)*req.PageSize, req.PageSize)
|
|
|
|
user := &cs.VistUser{
|
|
|
|
if err != nil {
|
|
|
|
Username: req.Username,
|
|
|
|
logrus.Errorf("Ds.GetUserPostStars err: %s", err)
|
|
|
|
RelTyp: relTyp,
|
|
|
|
return nil, web.ErrGetStarsFailed
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
totalRows, err := s.Ds.GetUserPostStarCount(req.User.ID)
|
|
|
|
if relTyp == cs.RelationSelf {
|
|
|
|
|
|
|
|
user.UserId = req.User.ID
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stars, totalRows, err := s.Ds.ListUserStarTweets(user, req.PageSize, (req.Page-1)*req.PageSize)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("Ds.GetUserPostStars err: %s", err)
|
|
|
|
logrus.Errorf("Ds.GetUserPostStars err: %s", err)
|
|
|
|
return nil, web.ErrGetStarsFailed
|
|
|
|
return nil, web.ErrGetStarsFailed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var posts []*ms.Post
|
|
|
|
var posts []*ms.Post
|
|
|
|
for _, star := range stars {
|
|
|
|
for _, star := range stars {
|
|
|
|
|
|
|
|
if star.Post != nil {
|
|
|
|
posts = append(posts, star.Post)
|
|
|
|
posts = append(posts, star.Post)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
postsFormated, err := s.Ds.MergePosts(posts)
|
|
|
|
postsFormated, err := s.Ds.MergePosts(posts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("Ds.MergePosts err: %s", err)
|
|
|
|
logrus.Errorf("Ds.MergePosts err: %s", err)
|
|
|
|