Skip to content

Commit

Permalink
edit community
Browse files Browse the repository at this point in the history
  • Loading branch information
vibern0 committed Jun 4, 2020
1 parent 145ba8f commit f0e9474
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/routes/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ export default (app: Router) => {
},
);

route.post(
'/edit',
celebrate({
body: Joi.object({
publicId: Joi.string().required(),
name: Joi.string().required(),
description: Joi.string().required(),
location: {
title: Joi.string().required(),
latitude: Joi.number().required(),
longitude: Joi.number().required(),
},
coverImage: Joi.string().required(),
}),
}),
async (req: Request, res: Response, next: NextFunction) => {
const {
publicId,
name,
description,
location,
coverImage,
} = req.body;
await CommunityService.edit(
publicId,
name,
description,
location,
coverImage,
);
res.sendStatus(200);
},
);

route.post(
'/accept',
celebrate({
Expand Down
19 changes: 19 additions & 0 deletions src/services/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ export default class CommunityService {
});
}

public static async edit(
publicId: string,
name: string,
description: string,
location: {
title: string,
latitude: number,
longitude: number,
},
coverImage: string,
) {
return Community.update({
name,
description,
location,
coverImage,
}, { returning: true, where: { publicId } });
}

public static async accept(acceptanceTransaction: string, publicId: string): Promise<boolean> {
const provider = new ethers.providers.JsonRpcProvider(config.jsonRpcUrl);
const receipt = await provider.waitForTransaction(acceptanceTransaction);
Expand Down

0 comments on commit f0e9474

Please sign in to comment.