@@ -882,6 +882,38 @@ bool attachment::is_remix() const {
882
882
return flags & a_is_remix;
883
883
}
884
884
885
+ time_t attachment::get_expire_time () const {
886
+ size_t attr_position = url.find (' ?' );
887
+ /* If no attributes were sent in url, we do not need to parse more */
888
+ if (url.npos == attr_position){
889
+ return 0 ;
890
+ }
891
+ std::string attributes = url.substr (attr_position + 1 );
892
+ std::vector<std::string> attr_list = utility::tokenize (attributes, " &" );
893
+ auto ex_attr = std::find_if (attr_list.begin (), attr_list.end (), [](const std::string& s){return s.substr (0 , 3 ) == " ex=" ;});
894
+ if (attr_list.end () == ex_attr){
895
+ return 0 ;
896
+ }
897
+ /* Erase 'ex=' prefix before parsing */
898
+ return std::stol (ex_attr->substr (3 ), nullptr , 16 );
899
+ }
900
+
901
+ time_t attachment::get_issued_time () const {
902
+ size_t attr_position = url.find (' ?' );
903
+ /* No attributes were sent in url, so we do not need to parse more */
904
+ if (url.npos == attr_position){
905
+ return 0 ;
906
+ }
907
+ std::string attributes = url.substr (attr_position + 1 );
908
+ std::vector<std::string> attr_list = utility::tokenize (attributes, " &" );
909
+ auto is_attr = std::find_if (attr_list.begin (), attr_list.end (), [](const std::string& s){return s.substr (0 , 3 ) == " is=" ;});
910
+ if (attr_list.end () == is_attr){
911
+ return 0 ;
912
+ }
913
+ /* Erase 'is=' prefix before parsing */
914
+ return std::stol (is_attr->substr (3 ), nullptr , 16 );
915
+ }
916
+
885
917
json message::to_json (bool with_id, bool is_interaction_response) const {
886
918
/* This is the basics. once it works, expand on it. */
887
919
json j ({
0 commit comments