Skip to content

Commit 5de1226

Browse files
committed
fix hydro balloon
1 parent faccab2 commit 5de1226

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/server/service/fetcher.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,17 @@ class HydroFetcher extends BasicFetcher {
177177
}
178178
const contest = body.tdoc;
179179
contest.freeze_time = contest.lockAt;
180-
const old = this?.contest?._id;
180+
const old = this?.contest?.id;
181181
this.contest = {
182182
info: contest, id: contest._id, name: contest.title, domainId,
183183
};
184-
this.logger.info(`Connected to ${contest.name}(id=${contest.id})`);
185-
return old === this.contest.id;
184+
this.logger.info(`Connected to ${this.contest.name}(id=${this.contest.id})`);
185+
return old !== this.contest.id;
186186
}
187187

188188
async getToken(username, password) {
189-
const res = await fetch('/login', 'post').send({ uname: username, password, rememberme: 'on' })
190-
.redirects(0).ok((i) => i.status === 302);
191-
if (!res) throw new Error('Failed to get token');
189+
const res = await fetch('/login', 'post').send({ uname: username, password, rememberme: 'on' }).redirects(0);
190+
if (!res || res.error) throw new Error('Failed to get token');
192191
config.token = `Bearer ${res.header['set-cookie'][0].split(';')[0].split('=')[1]}`;
193192
}
194193

@@ -230,7 +229,7 @@ class HydroFetcher extends BasicFetcher {
230229
contestproblem,
231230
team: body.udict[balloon.uid].displayName,
232231
teamid: balloon.uid,
233-
location: body.udict[balloon.uid].studentId,
232+
location: body.udict[balloon.uid].uname,
234233
affiliation: body.udict[balloon.uid].school,
235234
awards: balloon.first ? 'First of Problem' : (
236235
this.contest.info.freeze_time && (balloon.time * 1000) > this.contest.info.freeze_time
@@ -260,6 +259,6 @@ const fetcherList = {
260259
};
261260

262261
export async function apply(ctx: Context) {
263-
if (config.type !== 'server') ctx.logger('fetcher').info('Fetch mode: ', config.type);
262+
if (config.type !== 'server') ctx.logger('fetcher').info('Fetch mode:', config.type);
264263
ctx.plugin(fetcherList[config.type]);
265264
}

0 commit comments

Comments
 (0)