profile: drop gravatar support

gravatar is owned by an external entity (Automattic) and we have an
unnecessary dep to this service. users can just upload a profile pic
This commit is contained in:
Girish Ramakrishnan
2025-06-08 12:42:13 +02:00
parent cd45046724
commit a93c85ebc9
13 changed files with 69 additions and 137 deletions
+6 -49
View File
@@ -10,9 +10,6 @@ const common = require('./common.js'),
expect = require('expect.js'),
speakeasy = require('speakeasy'),
superagent = require('../../superagent.js'),
fs = require('fs'),
path = require('path'),
paths = require('../../paths.js'),
tokens = require('../../tokens.js');
describe('Profile API', function () {
@@ -309,13 +306,9 @@ describe('Profile API', function () {
describe('avatar', function () {
let customAvatarSize = 0;
it('placeholder by default', async function () {
const defaultAvatar = fs.readFileSync(path.join(paths.DASHBOARD_DIR, '/img/avatar-default-symbolic.svg'));
const response = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`);
expect(response.headers['content-type']).to.equal('image/svg+xml');
expect(response.body).to.eql(defaultAvatar);
it('empty by default', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`).ok(() => true);
expect(response.status).to.be(404);
});
it('can set custom avatar', async function () {
@@ -329,47 +322,11 @@ describe('Profile API', function () {
});
it('did set custom avatar', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: user.token });
expect(response.body.avatarUrl).to.contain('/api/v1/profile/avatar/');
const response2 = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`)
const response = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`)
.ok(() => true);
expect(parseInt(response2.headers['content-length'])).to.equal(customAvatarSize);
expect(response2.status).to.equal(200);
});
it('can set gravatar', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/profile/avatar`)
.query({ access_token: user.token })
.send({ avatar: 'gravatar' });
expect(response.status).to.be(202);
});
it('did set gravatar', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: user.token });
expect(response.body.avatarType).to.contain('gravatar');
});
it('can unset avatar', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/profile/avatar`)
.query({ access_token: user.token })
.send({ avatar: '' });
expect(response.status).to.be(202);
});
it('did unset avatar', async function () {
const defaultAvatar = fs.readFileSync(path.join(paths.DASHBOARD_DIR, '/img/avatar-default-symbolic.svg'));
const response = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`);
expect(response.headers['content-type']).to.equal('image/svg+xml');
expect(response.body).to.eql(defaultAvatar);
expect(parseInt(response.headers['content-length'])).to.equal(customAvatarSize);
expect(response.status).to.equal(200);
});
});