修复(#128): 修复家庭成员邀请流水可见性
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -113,12 +113,17 @@ func (l *GetInviteRecordsLogic) GetInviteRecords(req *types.GetInviteRecordsRequ
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "query orders failed: %v", err.Error())
|
||||
}
|
||||
|
||||
visibleUserIdSet := make(map[int64]struct{}, len(visibleUserIds))
|
||||
for _, userId := range visibleUserIds {
|
||||
visibleUserIdSet[userId] = struct{}{}
|
||||
}
|
||||
|
||||
allRecords := make([]types.InviteRecord, 0, len(parsedLogs))
|
||||
for _, parsed := range parsedLogs {
|
||||
content := parsed.content
|
||||
logItem := parsed.log
|
||||
orderInfo, hasOrder := orders[content.OrderNo]
|
||||
if !l.canViewInviteRecord(u.Id, logItem.ObjectId, hasOrder, orderInfo) {
|
||||
if !l.canViewInviteRecord(u.Id, logItem.ObjectId, visibleUserIdSet, hasOrder, orderInfo) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -177,17 +182,17 @@ func (l *GetInviteRecordsLogic) resolveInviteRecordVisibleUserIds(currentUserId
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (l *GetInviteRecordsLogic) canViewInviteRecord(currentUserId, logObjectId int64, hasOrder bool, orderInfo inviteOrderUser) bool {
|
||||
func (l *GetInviteRecordsLogic) canViewInviteRecord(currentUserId, logObjectId int64, visibleUserIds map[int64]struct{}, hasOrder bool, orderInfo inviteOrderUser) bool {
|
||||
if _, ok := visibleUserIds[logObjectId]; !ok {
|
||||
return false
|
||||
}
|
||||
if logObjectId == currentUserId {
|
||||
if hasOrder {
|
||||
return orderInfo.UserId == currentUserId || orderInfo.RefererId == currentUserId
|
||||
}
|
||||
return true
|
||||
}
|
||||
if !hasOrder {
|
||||
return false
|
||||
}
|
||||
return orderInfo.UserId == currentUserId && orderInfo.SubscriptionUserId == logObjectId
|
||||
return true
|
||||
}
|
||||
|
||||
func normalizeInviteRecordsPagination(req *types.GetInviteRecordsRequest) {
|
||||
|
||||
Reference in New Issue
Block a user