-
Notifications
You must be signed in to change notification settings - Fork 0
/
note.txt
225 lines (192 loc) · 6.28 KB
/
note.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
lightgray #f3f3f3
brand color #0a3d62
You may use http://cpanel.ogabike.com or https://cpanel-s18.registrar-servers.com, you don't need to mix them into one link.
if (payload.post.file === undefined) {
// !====user is not posting with image
return new_supabase
.from("feeds")
.insert([
{
feed_id: postId,
poster: poster,
posterId: id,
school: poster.school,
data: new_payload,
time: JSON.stringify(payload.post.time),
privacy: setPostPrivacy,
},
])
.then((res) => {
if (res.body === null) {
console.log(res);
state.draft.push(new_payload);
disp_draft(state.draft);
return error(
"Your operation could not be completed due to network error. Your post has been save to draft."
);
} else {
let newData = {
...res.body[0].data,
likes: [],
unlikes: [],
comments: [],
success: true,
};
state.feeds.push(newData);
loadFeeds(state.feeds);
console.log(res.body[0]);
return success("Done", { success: true });
}
})
.catch((error) => {
state.draft.push(new_payload);
disp_draft(state.draft);
return error(
"Your operation could not be completed due to network error. Your post has been save to draft."
);
});
} else {
// @====== user is posting with image
// @========== AT THIS POINT, MAKE A AXIOS CALL TO THE BACKEND TO UPLOAD THE IMAGE AND REPLACE THE URL
// if (payload.post.file === undefined) {
// !====user is not posting with image
// let file = "";
// if (payload.post.file !== undefined) {
// file = payload.post.file;
// }
// const formData = new FormData();
// formData.append("file", file);
// formData.append("upload_preset", "rx54xe0r");
// formData.append("folder", "aluta-meta-feed-posts");
// return fetch("https://api.cloudinary.com/v1_1/aluta-meta/upload", {
// method: "POST",
// body: formData,
// })
// .then((res) => res.json())
// .then((res) => {
// console.log(res);
// let newDataToUpload = {
// ...payload,
// post: { ...payload.post, file: res, photo: res.public_id },
// poster,
// id: postId,
// setPostPrivacy,
// };
// return new_supabase
// .from("feeds")
// .insert([
// {
// feed_id: postId,
// poster: poster,
// school: poster.school,
// posterId: id,
// data: newDataToUpload,
// time: JSON.stringify(payload.post.time),
// privacy: setPostPrivacy,
// },
// ])
// .then((res) => {
// if (res.body === null) {
// console.log(res);
// state.draft.push(newDataToUpload);
// disp_draft(state.draft);
// return error(
// "Your operation could not be completed due to network error. Your post has been save to draft."
// );
// } else {
// let newData = {
// ...res.body[0].data,
// likes: [],
// unlikes: [],
// comments: [],
// success: true,
// };
// state.feeds.push(newData);
// loadFeeds(state.feeds);
// console.log(res.body[0]);
// return success("Done", { success: true });
// }
// });
// })
// .catch((error) => {
// state.draft.push(new_payload);
// disp_draft(state.draft);
// return error(
// "Your operation could not be completed due to network error. Your post has been save to draft."
// );
// });
let file = "";
let fileExt = "";
let fileName = "";
let filePath = "";
if (payload.post.file !== undefined) {
file = payload.post.file;
fileExt = file.name.split(".").pop();
fileName = `${Math.random()}.${fileExt}`;
filePath = `${fileName}`;
}
let new_payload = { ...payload, poster, id: postId, setPostPrivacy };
return new_supabase.storage
.from("posts")
.upload(filePath, file, {
cacheControl: "3600",
upsert: false,
})
.then((resAvater) => {
if (resAvater.error === null) {
console.log(resAvater);
let newDataToUpload = {
...payload,
post: { ...payload.post, photo: resAvater.data.Key },
poster,
id: postId,
setPostPrivacy,
};
return new_supabase
.from("feeds")
.insert([
{
feed_id: postId,
poster: poster,
school: poster.school,
posterId: id,
data: newDataToUpload,
time: JSON.stringify(payload.post.time),
privacy: setPostPrivacy,
},
])
.then((res) => {
if (res.body === null) {
console.log(res);
state.draft.push(newDataToUpload);
disp_draft(state.draft);
return error(
"Your operation could not be completed due to network error. Your post has been save to draft."
);
} else {
let newData = {
...res.body[0].data,
likes: [],
unlikes: [],
comments: [],
success: true,
};
state.feeds.push(newData);
loadFeeds(state.feeds);
console.log(res.body[0]);
return success("Done", { success: true });
}
});
} else {
}
})
.catch((error) => {
state.draft.push(new_payload);
disp_draft(state.draft);
return error(
"Your operation could not be completed due to network error. Your post has been save to draft."
);
});
}
//////
Options to verify students, graduates, and lecturers.