Skip to content

Commit

Permalink
✨ feat: Add default profile image for initial login when Line does no…
Browse files Browse the repository at this point in the history
…t provide one

Replaced missing profile images with a specific default image for users logging in via Line for the first time.

Related issue: #349
  • Loading branch information
regulus0811 committed Nov 14, 2024
1 parent a3b8d9e commit 5956695
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion repositories/line_auth_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ func NewLINEAuthRepository(db *gorm.DB) LINEAuthRepository {
func (repo *lineAuthRepository) UpdateOrCreateUser(userInput dto.LineUserInput) (models.User, error) {
var user models.User
result := repo.db.Where("p_id = ?", fmt.Sprint(userInput.UserID)).First(&user)
if result.Error != nil && result.Error == gorm.ErrRecordNotFound {

defaultImageURL := "https://storage.sekai.best/sekai-jp-assets/stamp/stamp0810_rip/stamp0810.png"

if result.Error != nil && result.Error == gorm.ErrRecordNotFound {
pidPrefix := userInput.UserID[:4]
uniqueName := fmt.Sprintf("%s#%s", userInput.DisplayName, pidPrefix)

pictureURL := userInput.PictureURL
if pictureURL == "" {
pictureURL = defaultImageURL
}

user = models.User{
PID: fmt.Sprint(userInput.UserID),
Name: uniqueName,
Expand Down

0 comments on commit 5956695

Please sign in to comment.