Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #1730 - Now all actions are modified #1744

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,17 @@ func GetFeeds(ctxUser *User, actorID, offset int64, isProfile bool) ([]*Action,
err := sess.Find(&actions)
return actions, err
}

// ChangeUsernameInAction changes the name of act_user_name & repo_user_name
func ChangeUsernameInAction(id int64, newUserName string) error {
ac := Action{
RepoUserName: newUserName,
ActUserName: newUserName,
}
_, err := x.
Cols("act_user_name", "repo_user_name").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only update act_user_name. And add another SQL update action set repo_user_name=? where repo_user_name=?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be possible because I don't have the oldUserName, you want me to add it to the function?
I am not sure to understand how you want me to code it.

Where("act_user_id = ?", id).
Update(ac)
log.Info("%v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err maybe nil

Copy link
Member Author

@DblK DblK May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove this line

return err
}
4 changes: 4 additions & 0 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,10 @@ func ChangeUserName(u *User, newUserName string) (err error) {
return fmt.Errorf("ChangeUsernameInPullRequests: %v", err)
}

if err = ChangeUsernameInAction(u.ID, newUserName); err != nil {
return fmt.Errorf("ChangeUsernameInAction: %v", err)
}

// Delete all local copies of repository wiki that user owns.
if err = x.
Where("owner_id=?", u.ID).
Expand Down