public async Task <string> PostAsync([FromBody] UserDto userDto) { var userData = new Dictionary <string, object>() { { "profile_pic", userDto.ProfilePictureUrl } }; try { // Add user to the Stream API await _streamApi.StreamClient.Users.Add(userDto.Username, userData); PasswordHasher ph = new PasswordHasher(); // Add user to the DB _database.GetInstance.Execute("INSERT INTO users (username, pass, pic_url) VALUES(@user, @pass, @pic)", new { user = userDto.Username, pass = ph.Hash(userDto.Password), pic = userDto.ProfilePictureUrl }); // Register user timeline to his profile (the user timeline will show his own posts) IStreamFeed userTimeline = _streamApi.StreamClient.Feed("timeline", userDto.Username); await userTimeline.FollowFeed("user", userDto.Username); // Follow the admin account with the welcome message (if the user registering is already RecYou ignore it) if (userDto.Username != "RecYou") { await userTimeline.FollowFeed("user", "RecYou"); } } catch (Exception e) { return(e.Message); } return(JWT.GenerateToken(userDto.Username)); }
public async Task PostAsync([FromBody] RelationDto rdto) { IStreamFeed userTimeline = _streamApi.StreamClient.Feed("timeline", User.Identity.Name); await userTimeline.FollowFeed("user", rdto.UserToFollowUnfollow); }