Use user avatar hash instead of calculating it from the email
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2020-01-09 19:02:33 +01:00
parent 31361ae1f4
commit 4d61a6e918
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 8 additions and 12 deletions

View File

@ -120,9 +120,9 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
});
return;
}
loadedCurrentUser = User(int.tryParse(currentUser), "", "");
loadedCurrentUser = User(int.tryParse(currentUser), "", "", "");
} catch (otherExceptions) {
loadedCurrentUser = User(int.tryParse(currentUser), "", "");
loadedCurrentUser = User(int.tryParse(currentUser), "", "", "");
}
setState(() {
_client = client;

View File

@ -1,22 +1,18 @@
import 'package:crypto/crypto.dart';
class User {
final int id;
final String email, username;
final String email, username, avatarHash;
User(this.id, this.email, this.username);
User(this.id, this.email, this.username, this.avatarHash);
User.fromJson(Map<String, dynamic> json)
: id = json['id'],
email = json['email'],
username = json['username'];
username = json['username'],
avatarHash = json['avatarUrl'];
toJSON() => {"id": this.id, "email": this.email, "username": this.username};
String avatarUrl() {
return "https://secure.gravatar.com/avatar/" +
md5
.convert((this.email ?? "").trim().toLowerCase().codeUnits)
.toString();
return "https://secure.gravatar.com/avatar/" + this.avatarHash;
}
}

View File

@ -7,7 +7,7 @@ import 'package:vikunja_app/models/user.dart';
import 'package:vikunja_app/service/services.dart';
// Data for mocked services
var _users = {1: User(1, 'test@testuser.org', 'test1')};
var _users = {1: User(1, 'test@testuser.org', 'test1', '')};
var _namespaces = {
1: Namespace(