Skip to content

Add GL_GROUP group avatars (auto-update)

Eric Eastwood requested to merge 2393-gl-group-avatars into develop

Add GL_GROUP group avatars (auto-update). Every 7 days, we look if the avatar on GitLab has changed (we already do this for GitHub).

Part of https://gitlab.com/gitlab-org/gitter/webapp/issues/2393

Dev notes

My quick link (need to clear cache): http://localhost:5000/api/private/avatars/group/i/5df865d638da38f1fa1ecd9f

db.groups.insert({
        "name" : "_test-gitlab-group-test-community",
        "uri" : "_test-gitlab-group-test-community",
        "lcUri" : "_test-gitlab-group-test-community",
        "lcHomeUri" : "_test-gitlab-group-test-community/home",
        "homeUri" : "_test-gitlab-group-test-community/home",
        "sd" : {
                "externalId" : "3281315",
                "linkPath" : "gitter-integration-tests-group",
                "public" : true,
                "admins" : "GL_GROUP_MAINTAINER",
                "members" : "PUBLIC",
                "type" : "GL_GROUP"
        },
});
db.groups.update({ "lcUri" : "_test-gitlab-group-test-community" }, {
        $unset: {
                "avatarUrl" : 1,
                "avatarCheckedDate" :1,
                "avatarVersion" : 1
        }
});

GitHub Avatars

GitHub has a nice predictable constructable URL: https://avatars.githubusercontent.com/<username-or-group>?s=<size>

GitLab Avatars

Avatars from GitLab don't have a predictable URL.

If there is a custom upload, then the filename is whatever you uploaded:

This MR isn't supporting user namespaces. But users use Gravatar unless you upload something,

TODO

Testing strategy

  1. Insert a new GitLab Gitter group into Mongo
    db.groups.insert({
            "name" : "_test-gitlab-group-test-community",
            "uri" : "_test-gitlab-group-test-community",
            "lcUri" : "_test-gitlab-group-test-community",
            "lcHomeUri" : "_test-gitlab-group-test-community/home",
            "homeUri" : "_test-gitlab-group-test-community/home",
            "sd" : {
                    "externalId" : "3281315",
                    "linkPath" : "gitter-integration-tests-group",
                    "public" : true,
                    "admins" : "GL_GROUP_MAINTAINER",
                    "members" : "PUBLIC",
                    "type" : "GL_GROUP"
            },
    });
  2. Get the group ID: db.groups.findOne({ "lcUri" : "_test-gitlab-group-test-community" })
  3. Visit http://localhost:5000/api/private/avatars/group/i/<groupId>, it will go to https://avatars.githubusercontent.com/undefined?s=128 but now the avatar is updated
  4. Empty cache and hard reload
  5. Visit http://localhost:5000/api/private/avatars/group/i/<groupId> again, it should go to https://assets.gitlab-static.net/uploads/-/system/group/avatar/3281315/test-avatar1.png?width=128?v=1

You can reset and test again by clearing out the avatar properties:

db.groups.update({ "lcUri" : "_test-gitlab-group-test-community" }, {
        $unset: {
                "avatarUrl" : 1,
                "avatarCheckedDate" :1,
                "avatarVersion" : 1
        }
});
Edited by Eric Eastwood

Merge request reports