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

[NEW] User avatars from external source #7929

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0a1d0b3
Implement feature to load user avatar from external avatar provider
mjovanovic0 Aug 27, 2017
227db7f
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Mar 1, 2018
9a297d4
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Apr 21, 2018
2e3673e
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Apr 21, 2018
cb7b2c8
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Apr 23, 2018
beb8687
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Apr 24, 2018
3e4a71c
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Apr 25, 2018
91aa45c
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Apr 28, 2018
08fa170
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 May 3, 2018
6a93f70
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 May 19, 2018
8eacc75
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Jun 27, 2018
ff63bbe
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Aug 27, 2018
d6ad2e3
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
mjovanovic0 Jan 24, 2019
4725040
Avatar External source moved to utils package
mjovanovic0 Jan 24, 2019
81b9039
Changed settings name to be more descriptive
mjovanovic0 Jan 24, 2019
f5e911c
removed accidentally added file
mjovanovic0 Jan 24, 2019
9b5b862
Fixed trailing spaces issue and how settings is referenced
mjovanovic0 Jan 24, 2019
4dd6eb1
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
sampaiodiego Feb 5, 2019
a2f6fa5
Add setting description
sampaiodiego Feb 8, 2019
0fdcbe1
Merge branch 'develop' into 7743-feature-user-avatar-from-external-so…
sampaiodiego Feb 8, 2019
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
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"Accounts_AvatarCacheTime_description": "Number of seconds the http protocol is told to cache the avatar images.",
"Accounts_AvatarResize": "Resize Avatars",
"Accounts_AvatarSize": "Avatar Size",
"Accounts_AvatarExternalProviderUrl": "Avatar External Provider URL",
"Accounts_AvatarExternalProviderUrl_Description": "Example: `https://acme.com/api/v1/{username}`",
"Accounts_BlockedDomainsList": "Blocked Domains List",
"Accounts_BlockedDomainsList_Description": "Comma-separated list of blocked domains",
"Accounts_BlockedUsernameList": "Blocked Username List",
Expand Down
6 changes: 6 additions & 0 deletions packages/rocketchat-lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ RocketChat.settings.addGroup('Accounts', function() {
value: true,
},
});

this.add('Accounts_AvatarExternalProviderUrl', '', {
type: 'string',
public: true,
});

this.add('Accounts_AvatarCacheTime', 3600, {
type: 'int',
i18nDescription: 'Accounts_AvatarCacheTime_description',
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-utils/lib/getAvatarUrlFromUsername.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Session } from 'meteor/session';
import { settings } from 'meteor/rocketchat:settings';

export const getAvatarUrlFromUsername = function(username) {
const externalSource = (settings.get('Accounts_AvatarExternalProviderUrl') || '').trim().replace(/\/$/, '');
if (externalSource !== '') {
return externalSource.replace('{username}', username);
}
const key = `avatar_random_${ username }`;
const random = typeof Session !== 'undefined' && typeof Session.keys[key] !== 'undefined' ? Session.keys[key] : 0;
if (username == null) {
Expand Down