Skip to content

Commit

Permalink
Fixing the bot badge (#2487)
Browse files Browse the repository at this point in the history
  • Loading branch information
jespino authored Mar 10, 2022
1 parent c518536 commit 07ffa8a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
11 changes: 6 additions & 5 deletions server/services/store/mattermostauthlayer/mattermostauthlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ func (s *MattermostAuthLayer) getUserByCondition(condition sq.Eq) (*model.User,

func (s *MattermostAuthLayer) getUsersByCondition(condition sq.Eq) (map[string]*model.User, error) {
query := s.getQueryBuilder().
Select("id", "username", "email", "password", "MFASecret as mfa_secret", "AuthService as auth_service", "COALESCE(AuthData, '') as auth_data",
"props", "CreateAt as create_at", "UpdateAt as update_at", "DeleteAt as delete_at").
From("Users").
Where(sq.Eq{"deleteAt": 0}).
Select("u.id", "u.username", "u.email", "u.password", "u.MFASecret as mfa_secret", "u.AuthService as auth_service", "COALESCE(u.AuthData, '') as auth_data",
"u.props", "u.CreateAt as create_at", "u.UpdateAt as update_at", "u.DeleteAt as delete_at", "b.UserId IS NOT NULL AS is_bot").
From("Users as u").
LeftJoin("Bots b ON ( b.UserId = u.ID )").
Where(sq.Eq{"u.deleteAt": 0}).
Where(condition)
row, err := query.Query()
if err != nil {
Expand All @@ -100,7 +101,7 @@ func (s *MattermostAuthLayer) getUsersByCondition(condition sq.Eq) (map[string]*

var propsBytes []byte
err := row.Scan(&user.ID, &user.Username, &user.Email, &user.Password, &user.MfaSecret, &user.AuthService,
&user.AuthData, &propsBytes, &user.CreateAt, &user.UpdateAt, &user.DeleteAt)
&user.AuthData, &propsBytes, &user.CreateAt, &user.UpdateAt, &user.DeleteAt, &user.IsBot)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ const Entry = (props: EntryComponentProps): ReactElement => {
/>
<div className={theme?.mentionSuggestionsEntryText}>
{mention.name}
{BotBadge &&
<BotBadge
show={mention.isBot}
/>
}
{BotBadge && <BotBadge show={mention.is_bot}/>}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
background: rgba(var(--button-bg-rgb), 0.08);
}

span {
.Badge {
margin-left: 12px;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Props = {
const MarkdownEditorInput = (props: Props): ReactElement => {
const {onChange, onFocus, onBlur, initialText, id, isEditing} = props
const boardUsers = useAppSelector<IUser[]>(getBoardUsersList)
const mentions: MentionData[] = useMemo(() => boardUsers.map((user) => ({name: user.username, avatar: `${imageURLForUser ? imageURLForUser(user.id) : ''}`})), [boardUsers])
const mentions: MentionData[] = useMemo(() => boardUsers.map((user) => ({name: user.username, avatar: `${imageURLForUser ? imageURLForUser(user.id) : ''}`, is_bot: user.is_bot})), [boardUsers])
const ref = useRef<Editor>(null)

const generateEditorState = (text?: string) => {
Expand Down

0 comments on commit 07ffa8a

Please sign in to comment.