mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-25 19:55:26 +03:00
34 lines
812 B
JavaScript
34 lines
812 B
JavaScript
import * as Serializers from "~/node_common/serializers";
|
|
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
export default async () => {
|
|
return await runQuery({
|
|
label: "GET_ALL_SENDGRID_CONTACTS",
|
|
queryFn: async (DB) => {
|
|
let query = await DB.select("id", "username", "email").from("users").whereNotNull("email");
|
|
|
|
if (!query || query.error) {
|
|
return null;
|
|
}
|
|
|
|
let formatted = query.map((user) => {
|
|
return {
|
|
email: user.email,
|
|
custom_fields: {
|
|
w4_T: user.id,
|
|
w5_T: user.username,
|
|
},
|
|
};
|
|
});
|
|
|
|
return JSON.parse(JSON.stringify(formatted));
|
|
},
|
|
errorFn: async (e) => {
|
|
return {
|
|
error: true,
|
|
decorator: "GET_ALL_SENDGRID_CONTACTS",
|
|
};
|
|
},
|
|
});
|
|
};
|