@@ -29,7 +29,6 @@ angular.module('mm.addons.messages')
2929 $log = $log . getInstance ( 'mmaMessagesDiscussionCtrl' ) ;
3030
3131 var userId = $stateParams . userId ,
32- userFullname = $stateParams . userFullname ,
3332 messagesBeingSent = 0 ,
3433 polling ,
3534 fetching ,
@@ -41,26 +40,27 @@ angular.module('mm.addons.messages')
4140 $scope . messages = [ ] ;
4241 $scope . userId = userId ;
4342 $scope . currentUserId = $mmSite . getUserId ( ) ;
44- $scope . profileLink = true ;
4543
46- if ( userFullname ) {
47- $scope . title = userFullname ;
48- } else if ( userId ) {
49- // We don't have the fullname, try to get it.
50- $mmUser . getProfile ( userId ) . then ( function ( user ) {
44+ // Disable the profile button if we're already coming from a profile.
45+ if ( backView && backView . stateName === mmUserProfileState ) {
46+ $scope . profileLink = false ;
47+ }
48+
49+ if ( userId ) {
50+ // Get the user profile to retrieve the user fullname and image.
51+ $mmUser . getProfile ( userId , undefined , true ) . then ( function ( user ) {
5152 if ( ! $scope . title ) {
5253 $scope . title = user . fullname ;
5354 }
55+ if ( typeof $scope . profileLink == 'undefined' ) {
56+ $scope . profileLink = user . profileimageurl ;
57+ }
58+ } ) . catch ( function ( ) {
59+ // Couldn't retrieve the image, use a default icon.
60+ $scope . profileLink = true ;
5461 } ) ;
5562 }
5663
57- // Disable the profile button if we're coming from a profile. It is safer to prevent forbid the access
58- // to the full profile (we do not know the course ID they came from) as some users cannot view the full
59- // profile of other users.
60- if ( backView && backView . stateName === mmUserProfileState ) {
61- $scope . profileLink = false ;
62- }
63-
6464 $scope . isAppOffline = function ( ) {
6565 return ! $mmApp . isOnline ( ) ;
6666 } ;
@@ -117,7 +117,7 @@ angular.module('mm.addons.messages')
117117 // Fetch the messages for the first time.
118118 $mmaMessages . getDiscussion ( userId ) . then ( function ( messages ) {
119119 $scope . messages = $mmaMessages . sortMessages ( messages ) ;
120- if ( ! userFullname && messages && messages . length > 0 ) {
120+ if ( ! $scope . title && messages && messages . length > 0 ) {
121121 // When we did not receive the fullname via argument. Also it is possible that
122122 // we cannot resolve the name when no messages were yet exchanged.
123123 if ( messages [ 0 ] . useridto != $scope . currentUserId ) {
0 commit comments